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

html {
    overflow-x: hidden;
    max-width: 100vw;
}

:root {
    --bg-main: #fafbfc;
    --bg-panel: #ffffff;
    --bg-hover: #f5f7fa;
    --bg-input: #ffffff;
    --bg-button: #eff6ff;
    --bg-button-hover: #e0f2fe;
    --bg-switch-inactive: #f1f3f4;
    --bg-switch-active: #e0f2fe;
    --bg-input-inactive: #f9fafb;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-link: #0369a1;
    --border-color: #e2e8f0;
    --blue-accent: #0369a1;
    --gemini-blue: #0284c7;
    --font-family: 'Google Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
    overflow-x: hidden;
    max-width: 100vw;
}

.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    overflow-x: hidden;
    flex-direction: row;
    max-width: 100vw;
}

/* Left Sidebar */
.left-sidebar {
    width: 240px;
    min-width: 180px;
    max-width: 600px;
    background-color: #ffffff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    order: 1;
    position: relative;
    transition: width 0.1s ease-out;
}

.left-sidebar.resizing {
    transition: none;
    user-select: none;
}

.left-sidebar.collapsed {
    width: 0;
    min-width: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.left-sidebar.collapsed ~ .sidebar-resize-handle {
    display: none;
}

.left-sidebar.collapsed ~ .main-content #expandSidebarBtn {
    display: flex !important;
}

/* Sidebar Resize Handle */
.sidebar-resize-handle {
    width: 4px;
    background-color: transparent;
    cursor: col-resize;
    position: relative;
    order: 2;
    flex-shrink: 0;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.sidebar-resize-handle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -3px;
    right: -3px;
    bottom: 0;
    background-color: transparent;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.resizing {
    background-color: var(--blue-accent);
}

.sidebar-resize-handle:hover::before,
.sidebar-resize-handle.resizing::before {
    background-color: rgba(3, 105, 161, 0.1);
}

body.resizing-sidebar {
    cursor: col-resize;
    user-select: none;
}

body.resizing-sidebar * {
    cursor: col-resize !important;
    user-select: none !important;
}

.sidebar-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.logo {
    font-size: 22px;
    font-weight: 500;
    padding: 8px 0;
}

.collapse-sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 6px;
    background-color: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.collapse-sidebar-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    transition: background-color 0.2s;
}

.nav-item.active {
    background-color: var(--bg-button);
    color: var(--blue-accent);
    border-radius: 8px;
    font-weight: 500;
}

.nav-item:not(.active):hover {
    background-color: var(--bg-hover);
}

.nav-item svg {
    margin-right: 16px;
    width: 20px;
    height: 20px;
}

/* History Section */
.history {
    margin-top: 32px;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 0;
}

.history h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
}

.history-collapse-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 20px;
    height: 20px;
}

.history-collapse-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.history-collapse-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.history.collapsed .history-collapse-btn svg {
    transform: rotate(-90deg);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 1000px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.history.collapsed .history-list {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.history-item {
    font-size: 14px;
    color: var(--text-secondary);
    padding: 8px 16px 8px 16px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-height: 40px;
}

.history-item:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
    padding-right: 68px; /* Make room for buttons */
}

.history-item.active {
    background-color: var(--bg-button);
    color: var(--blue-accent);
    font-weight: 500;
}

.history-item-text {
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    max-height: calc(1.4em * 2);
}

.history-item-actions {
    position: absolute;
    right: 8px;
    top: 8px;
    display: none;
    gap: 4px;
    align-items: center;
}

.history-item:hover .history-item-actions {
    display: flex;
}

.history-item-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 24px;
    height: 24px;
}

.history-item-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.history-item-btn.delete:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.history-item-btn svg {
    width: 14px;
    height: 14px;
}

/* Edit mode for history items */
.history-item.editing {
    padding: 4px 8px;
}

.history-item.editing .history-item-text {
    display: none;
}

.history-item.editing .history-item-actions {
    display: none;
}

.history-edit-form {
    display: none;
    flex: 1;
    gap: 4px;
}

.history-item.editing .history-edit-form {
    display: flex;
}

.history-edit-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--blue-accent);
    border-radius: 4px;
    font-size: 14px;
    font-family: var(--font-family);
    outline: none;
}

.history-edit-input:focus {
    border-color: var(--blue-accent);
    box-shadow: 0 0 0 2px rgba(3, 105, 161, 0.1);
}

.history-edit-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.history-edit-btn.save {
    color: var(--blue-accent);
}

.history-edit-btn.save:hover {
    background-color: var(--bg-button);
}

.history-edit-btn.cancel {
    color: var(--text-secondary);
}

.history-edit-btn.cancel:hover {
    background-color: var(--bg-hover);
}

.history-edit-btn svg {
    width: 16px;
    height: 16px;
}

.history-item-loading {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.history-item-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    font-style: italic;
}

.history-loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--blue-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.load-more-history {
    width: 100%;
    padding: 8px 16px;
    margin-top: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-link);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.load-more-history:hover {
    background-color: var(--bg-hover);
    border-color: var(--blue-accent);
}

.load-more-history:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 16px 0;
}

.privacy-mode-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 16px;
    background-color: var(--bg-hover);
    border-radius: 8px;
    transition: background-color 0.2s;
}

.privacy-mode-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.privacy-mode-label svg {
    color: var(--text-secondary);
}

.sidebar-footer-text {
    margin-bottom: 16px;
}

.privacy-mode-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 12px;
    background-color: var(--bg-panel);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.privacy-mode-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.privacy-mode-label svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
}

.sidebar-footer-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-footer-links a {
    text-decoration: none;
    color: var(--text-link);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 8px 16px;
    transition: opacity 0.2s;
}

.sidebar-footer-links a:hover {
    opacity: 0.8;
}

.sidebar-footer-links a svg {
    width: 16px;
    height: 16px;
}

/* Sidebar User Profile */
.sidebar-user-profile {
    margin-bottom: 20px;
    padding-bottom: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px;
    background-color: var(--bg-hover);
    border-radius: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: var(--blue-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
}

.user-details {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.user-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.user-email {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.signout-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 6px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s;
}

.signout-button:hover {
    background-color: var(--bg-hover);
    border-color: var(--blue-accent);
    color: var(--blue-accent);
}

.signout-button svg {
    flex-shrink: 0;
}

/* Visitor Info Styles */
.visitor-info {
    margin-top: 4px;
}

.visitor-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--blue-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.visitor-status-badge svg {
    width: 14px;
    height: 14px;
}

.visitor-expiry {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    background-color: var(--bg-main);
    border-radius: 12px;
    margin: 8px;
    overflow: hidden;
    overflow-x: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    height: calc(100vh - 16px);
    order: 3;
    position: relative;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 24px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    color: var(--text-primary);
}

.main-header .title {
    font-size: 18px;
    font-weight: 500;
}

.model-selector-header {
    display: flex;
    align-items: center;
    margin: 0 12px;
}

.model-selector-header select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    padding: 4px 24px 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    min-width: 140px;
    outline: none;
    transition: background-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 4px center;
    background-repeat: no-repeat;
    background-size: 16px;
}

.model-selector-header select:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.model-selector-header select:focus {
    background-color: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.main-header-icons {
    display: flex;
    gap: 8px;
}

.icon-button {
    background-color: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: background-color 0.2s;
}

.icon-button:hover {
    background-color: var(--bg-hover);
}

.icon-button svg {
    font-size: 20px;
}

.chat-container {
    max-width: 800px;
    margin: auto;
    text-align: center;
    width: 100%;
    padding: 24px;
}

.chat-container h1 {
    font-size: 44px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 24px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease-in;
}

.message-wrapper.user {
    align-self: flex-end;
}

.message-wrapper.assistant {
    align-self: flex-start;
}

/* Greyed-out messages (outside history window) */
.message-wrapper.outside-history {
    opacity: 0.4;
    position: relative;
    transition: opacity 0.3s ease;
}

.message-wrapper.outside-history::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(128, 128, 128, 0.05);
    pointer-events: none;
    border-radius: 12px;
}

.message-wrapper.outside-history:hover {
    opacity: 0.6;
}

/* Optional: Add a tooltip indicator for outside-history messages */
.message-wrapper.outside-history .message-content::before {
    content: 'Outside context window';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.message-wrapper.outside-history .message-content:hover::before {
    opacity: 1;
}

.model-label {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
    margin-left: 48px;
    font-weight: 500;
}

.message {
    display: flex;
    gap: 12px;
    width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
}

.message.assistant {
    flex-direction: row;
}

.message.thinking {
    flex-direction: row;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    font-weight: 500;
}

.message.user .message-avatar {
    background: #0369a1;
    color: white;
}

.message.assistant .message-avatar {
    background: #94a3b8;
    color: white;
}

.message.thinking .message-avatar {
    background: #cbd5e1;
    color: #64748b;
}

.message-content {
    background-color: var(--bg-panel);
    padding: 12px 16px;
    border-radius: 18px;
    border: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.message.user .message-content {
    background: #0369a1;
    color: #ffffff;
}

.message.assistant .message-content {
    background-color: var(--bg-panel);
}

.message-text {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    word-wrap: break-word;
}

/* Markdown Styles - Tables */
.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 0.95em;
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.08);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.message-text th,
.message-text td {
    padding: 12px 16px;
    text-align: left;
    vertical-align: middle;
    border: none;
}

.message-text th:last-child,
.message-text td:last-child {
    border-right: 0;
}

.message-text thead th {
    background-color: var(--bg-button);
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: none;
}

.message-text tbody tr {
    background-color: var(--bg-panel);
    transition: background-color 0.2s ease;
}

.message-text tbody tr:nth-of-type(even) {
    background-color: var(--bg-main);
}

.message-text tbody tr:hover {
    background-color: var(--bg-hover);
}

.message-text tbody tr:last-of-type td {
    border-bottom: 0;
}

.message-text td ul,
.message-text td ol {
    margin: 0;
    padding-left: 20px;
}

.message-text td p {
    margin: 0 0 0.5em 0;
}

.message-text td p:last-child {
    margin-bottom: 0;
}

/* Mermaid Diagram Styles */
.message-text .mermaid-preview-wrapper {
    margin: 1em 0;
}

/* The code block stays as-is with existing styles */
.message-text .mermaid-preview-wrapper > pre {
    margin-bottom: 0;
}

/* Preview container - similar to HTML preview */
.message-text .mermaid-preview-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 0.5em;
    background-color: var(--bg-main);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.08);
}

.message-text .mermaid-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background-color: var(--bg-hover);
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-family);
}

.message-text .mermaid-preview-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-text .mermaid-preview-title svg {
    color: var(--blue-accent);
}

.message-text .mermaid-open-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-button);
    color: var(--blue-accent);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.message-text .mermaid-open-btn:hover {
    background: var(--bg-button-hover);
    border-color: var(--blue-accent);
    transform: translateY(-1px);
}

.message-text .mermaid-open-btn svg {
    flex-shrink: 0;
}

.message-text .mermaid-preview-content {
    padding: 2em 1em;
    background: var(--bg-panel);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.message-text .mermaid-preview-content .mermaid {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

.message-text .mermaid-preview-content .mermaid.mermaid-rendered {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.message-text .mermaid-preview-content .mermaid svg {
    max-width: 100%;
    height: auto;
    overflow: visible;
}

.message-text .mermaid-preview-content .mermaid svg .edgeLabel text {
    fill: var(--text-primary) !important;
}

/* Additional Mermaid SVG styling overrides */
.message-text .mermaid-preview-content .mermaid svg .node rect {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
    rx: 12px !important;  /* Rounded corners */
    ry: 12px !important;  /* Rounded corners */
    stroke: none !important;  /* Remove border */
    stroke-width: 0 !important;  /* Remove border */
}

.message-text .mermaid-preview-content .mermaid svg .node circle,
.message-text .mermaid-preview-content .mermaid svg .node polygon {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
    stroke: none !important;  /* Remove border */
    stroke-width: 0 !important;  /* Remove border */
}

/* Diamond shapes (decision nodes) */
.message-text .mermaid-preview-content .mermaid svg .node polygon {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
}

.message-text .mermaid-preview-content .mermaid svg .edgeLabel {
    /* Note: background-color doesn't work on SVG <g> elements */
}

.message-text .mermaid-preview-content .mermaid svg .edgeLabel rect {
    fill: white !important;
    stroke: none !important;
    opacity: 0.95;
}

.message-text .mermaid-preview-content .mermaid svg text {
    font-family: var(--font-family) !important;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Styling for htmlLabels in Mermaid to force word wrapping */
.message-text .mermaid-preview-content .mermaid svg .node div {
    white-space: normal !important;
    word-wrap: break-word !important;
    text-align: center !important;
    display: table-cell !important;
    vertical-align: middle !important;
    width: 100% !important;
}

/* Cluster/subgraph backgrounds */
.message-text .mermaid-preview-content .mermaid svg .cluster rect {
    rx: 12px !important;
    ry: 12px !important;
    stroke: none !important;
}

/* Markdown Styles - Headings */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    color: var(--blue-accent);
    line-height: 1.3;
    font-weight: 600;
    margin-top: 2em;
    margin-bottom: 0.8em;
}

.message-text h1 { font-size: 1.5em; }
.message-text h2 { font-size: 1.4em; }
.message-text h3 { font-size: 1.2em; }

.message-text h1:first-child,
.message-text h2:first-child,
.message-text h3:first-child {
    margin-top: 0;
}

.message-text p {
    margin-top: 0.8em;
    margin-bottom: 0.8em;
}

.message-text p:first-child {
    margin-top: 0;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text ul,
.message-text ol {
    margin-bottom: 1em;
    padding-left: 28px;
    margin-top: 1em;
}

.message-text h1 + ul, .message-text h1 + ol,
.message-text h2 + ul, .message-text h2 + ol,
.message-text h3 + ul, .message-text h3 + ol {
    margin-top: 0.8em;
}

.message-text li {
    margin-bottom: 0.6em;
    padding-left: 8px;
    line-height: 1.6;
}

.message-text li::marker {
    color: var(--blue-accent);
}

.message-text ul ul,
.message-text ol ul,
.message-text ul ol,
.message-text ol ol {
    margin-top: 0.5em;
    padding-left: 25px;
}

.message-text strong {
    color: var(--text-primary);
    font-weight: 600;
}

.message-text > *:first-child {
    margin-top: 0;
}

.message-text > *:last-child {
    margin-bottom: 1.0em;
}

/* Code Container with Header */
.message-text .code-container {
    position: relative;
    margin: 1em 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.08);
}

.message-text .code-container pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 2.5em 1em 1em 1em;
    border-radius: 0 0 8px 8px;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    max-height: 500px;
    overflow-y: auto;
}

.message-text .code-container pre code {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    padding: 0;
    background: transparent;
    color: inherit;
}

.message-text .code-container pre code.hljs {
    background: transparent !important;
    color: #e2e8f0;
}

.message-text .code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--text-primary);
    padding: 8px 16px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.message-text .code-header-buttons {
    display: flex;
    gap: 8px;
}

.message-text .language-name {
    color: var(--text-secondary);
    font-size: 0.75em;
    font-family: var(--font-family);
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.message-text .copy-code-button {
    background-color: transparent;
    color: #94a3b8;
    border: 1px solid #475569;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.75em;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    font-weight: 500;
}

.message-text .copy-code-button:hover {
    background-color: var(--blue-accent);
    color: white;
    border-color: var(--blue-accent);
}

.message-text .copy-code-button:active {
    transform: scale(0.95);
}

/* Table Container with Header */
.message-text .table-container {
    position: relative;
    margin: 1em 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
}

.message-text .table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(248, 250, 252, 0.5);
    padding: 4px 12px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

.message-text .table-label {
    color: #94a3b8;
    font-size: 0.7em;
    font-family: var(--font-family);
    text-transform: uppercase;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.message-text .copy-table-button {
    background-color: transparent;
    color: #94a3b8;
    border: none;
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 0.7em;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    font-weight: 400;
    opacity: 0.7;
}

.message-text .copy-table-button:hover {
    background-color: rgba(3, 105, 161, 0.1);
    color: var(--blue-accent);
    opacity: 1;
}

.message-text .copy-table-button:active {
    transform: scale(0.95);
}

.message-text .table-container table {
    margin: 0 !important;
    border-radius: 0 !important;
}

/* User message table styles */
.message.user .message-text .table-container {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.message.user .message-text .table-header {
    background-color: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.message.user .message-text .table-label {
    color: rgba(255, 255, 255, 0.6);
}

.message.user .message-text .copy-table-button {
    color: rgba(255, 255, 255, 0.6);
    border: none;
    opacity: 0.7;
}

.message.user .message-text .copy-table-button:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    opacity: 1;
}

/* Inline code - not in code blocks */
.message-text code {
    background-color: var(--bg-hover);
    color: var(--blue-accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    border: 1px solid var(--border-color);
}

/* Override for code blocks */
.message-text pre code,
.message-text .code-container code {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    border: none !important;
}

/* Blockquotes */
.message-text blockquote {
    border-left: 4px solid var(--blue-accent);
    background-color: var(--bg-button);
    padding: 12px 16px;
    margin-left: 0;
    margin: 1em 0;
    color: var(--text-secondary);
    font-style: italic;
    border-radius: 4px;
}

/* Links */
.message-text a {
    color: var(--text-link);
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

/* Images */
.message-text img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
}

/* Horizontal rules */
.message-text hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 1.5em 0;
    opacity: 0.5;
}

/* KaTeX/LaTeX Styles */
.message-text .katex {
    font-size: 1.1em;
}

.message-text .katex-display {
    margin: 1em 0;
    overflow-x: auto;
    overflow-y: hidden;
    text-align: center;
}

.message-text .katex-inline {
    font-size: 1em;
}

.message-text .katex-html {
    white-space: nowrap;
}

.message-text .katex-display > .katex {
    display: inline-block;
    white-space: nowrap;
    max-width: 100%;
}

.message-text td .katex,
.message-text th .katex {
    font-size: 0.95em;
}

/* HTML Preview Styles */
.message-text .html-preview-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 1em;
    background-color: var(--bg-main);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.08);
}

.message-text .html-preview-header {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background-color: var(--bg-hover);
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-family);
}

.message-text .html-inline-preview {
    width: 100%;
    height: 300px;
    max-height: 500px;
    border: none;
    margin: 0;
    background-color: white;
    resize: vertical;
    overflow: auto;
    display: block;
}

.message.user .message-text {
    color: #ffffff;
    font-weight: 400;
    white-space: pre-wrap;
}

.message.user .message-text code {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-text pre code,
.message.user .message-text .code-container code {
    background: transparent !important;
    color: inherit !important;
}

.message.user .message-text h1,
.message.user .message-text h2,
.message.user .message-text h3 {
    color: #ffffff;
}

.message.user .message-text strong {
    color: #ffffff;
}

.message.user .message-text a {
    color: #e0f2fe;
    text-decoration: underline;
}

.message.user .message-text blockquote {
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

.message.user .message-text .code-container {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message.user .message-text .code-container pre {
    background-color: rgba(0, 0, 0, 0.4);
    color: #ffffff;
}

.message.user .message-text .code-header {
    background-color: rgba(0, 0, 0, 0.5);
}

.message.user .message-text .language-name {
    color: rgba(255, 255, 255, 0.8);
}

.message.user .message-text .copy-code-button {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-text .copy-code-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.5);
}

.message.user .message-text li::marker {
    color: rgba(255, 255, 255, 0.9);
}

.message.user .message-text table {
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.message.user .message-text th,
.message.user .message-text td {
    border: none;
}

.message.user .message-text thead th {
    background-color: rgba(0, 0, 0, 0.2);
    color: #ffffff;
    border-bottom: none;
}

.message.user .message-text tbody tr {
    background-color: rgba(255, 255, 255, 0.05);
}

.message.user .message-text tbody tr:nth-of-type(even) {
    background-color: rgba(255, 255, 255, 0.1);
}

.message.user .message-text tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.message-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
    text-align: right;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.85);
}

/* Message Actions */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.message-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 13px;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-family);
}

.message-action-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.message-action-btn svg {
    flex-shrink: 0;
}

.message.user .message-actions {
    border-top-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-action-btn {
    color: rgba(255, 255, 255, 0.85);
}

.message.user .message-action-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 1);
}

/* Delete button specific styles */
.message-action-btn.delete-btn:hover {
    background-color: #fee;
    color: #c53030;
}

.message.user .message-action-btn.delete-btn:hover {
    background-color: rgba(255, 100, 100, 0.3);
    color: #fff;
}

/* Thinking Block Styles */
.message.thinking .message-content {
    background-color: #f8f9fa;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    user-select: none;
}

.message.thinking .message-text {
    color: #64748b;
    font-size: 14px;
    font-style: italic;
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 8px;
}

.thinking-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.thinking-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
}

.thinking-toggle {
    font-size: 12px;
    transition: transform 0.2s;
}

.thinking-content {
    max-height: 500px;
    overflow-y: auto;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.thinking-content.collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

.thinking-content::-webkit-scrollbar {
    width: 6px;
}

.thinking-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

.chat-input-container {
    padding: 4px 16px 16px 16px;
    background-color: transparent;
    flex-shrink: 0;
}

.prompt-area {
    position: relative;
    margin-bottom: 0;
    padding: 4px;
    border: 1px solid var(--border-color);
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    transition: box-shadow 0.2s;
    background-color: var(--bg-panel);
}

.prompt-area:focus-within {
    border-color: var(--blue-accent);
    box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.1);
}

.prompt-input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.prompt-input {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-family: var(--font-family);
    background-color: transparent;
    resize: none;
    min-height: 28px;
    max-height: 200px;
    overflow-y: hidden;
    overflow-wrap: break-word;
    line-height: 1.5;
}

.prompt-input:focus {
    outline: none;
}

.prompt-input.drag-over {
    background-color: var(--bg-hover);
    border: 2px dashed var(--blue-accent);
    border-radius: 28px;
}

.prompt-buttons {
    position: static;
    transform: none;
    display: flex;
    gap: 8px;
    align-items: center;
    padding-right: 8px;
}

.prompt-buttons button {
    background-color: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    font-size: 18px;
    color: var(--text-secondary);
}

.prompt-buttons button:hover {
    background-color: var(--bg-hover);
}

.prompt-buttons .run-btn {
    background-color: var(--bg-hover);
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.prompt-buttons .run-btn span {
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    display: none;
}

.prompt-buttons .run-btn:hover {
    background-color: #e0e0e0;
}

.prompt-buttons .run-btn svg {
    width: 16px;
    height: 16px;
}

.prompt-buttons .run-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Queue Button */
.prompt-buttons .queue-btn {
    background-color: var(--bg-hover);
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.prompt-buttons .queue-btn span {
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    display: none;
}

.prompt-buttons .queue-btn:hover {
    background-color: #e0e0e0;
}

.prompt-buttons .queue-btn svg {
    width: 16px;
    height: 16px;
}

.prompt-buttons .queue-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Queued Message Indicator */
.queued-message-indicator {
    background: #f1f5f9;
    border: none;
    border-radius: 14px;
    padding: 10px 14px;
    margin: 0 16px 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: queueSlideIn 0.3s ease-out;
}

@keyframes queueSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.queued-message-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.queued-icon {
    color: #3b82f6;
    flex-shrink: 0;
}

.queued-label {
    font-weight: 600;
    font-size: 13px;
    color: #475569;
    flex-shrink: 0;
}

.queued-preview {
    font-size: 13px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    line-height: 1.5;
}

.clear-queue-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    color: #94a3b8;
}

.clear-queue-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.clear-queue-btn svg {
    width: 13px;
    height: 13px;
}

/* Attachment Button */
.attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent !important;
    border: none;
    cursor: pointer;
    padding: 8px !important;
    border-radius: 50% !important;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.attach-btn:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary);
}

.attach-btn svg {
    width: 20px;
    height: 20px;
}

/* Attachments Preview */
.attachments-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background-color: var(--bg-input-inactive);
    border-radius: 12px;
    margin-bottom: 8px;
}

.attachment-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-primary);
    max-width: 200px;
}

.attachment-item.uploading {
    opacity: 0.6;
}

.attachment-item img.attachment-thumbnail {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
}

.attachment-item .attachment-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-hover);
    border-radius: 4px;
    color: var(--text-secondary);
}

.attachment-item .attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-item .attachment-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-item .attachment-size {
    font-size: 11px;
    color: var(--text-secondary);
}

.attachment-item .remove-attachment {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background-color: var(--text-secondary);
    color: white;
    border: 2px solid var(--bg-panel);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    transition: background-color 0.2s;
}

.attachment-item .remove-attachment:hover {
    background-color: #ef4444;
}

/* Message Attachments */
.message-attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.message-attachment-image {
    display: inline-block;
}

.message-attachment-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.message-attachment-file {
    display: inline-block;
    padding: 6px 12px;
    background-color: var(--bg-hover);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Right Sidebar */
.right-sidebar {
    width: 320px;
    background-color: var(--bg-panel);
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow: hidden;
    border-radius: 12px;
    margin: 8px;
    margin-left: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: width 0.3s ease, margin 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    order: 4;
}

.right-sidebar.collapsed {
    width: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
}

/* Hide settings button when panel is expanded */
#toggleSettingsBtn {
    display: none;
}

.right-sidebar.collapsed ~ .main-content #toggleSettingsBtn {
    display: flex;
}

.settings {
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.settings-header h2 {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
}

.settings-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-close-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.settings-close-btn svg {
    font-size: 20px;
}

.setting-group {
    margin-bottom: 0;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    margin-top: 32px;
}

.setting-group:first-child {
    margin-top: 0;
    padding-top: 0;
}

 .setting-group.no-border {
     border-bottom: none;
 }

 .setting-item {
     margin-bottom: 24px;
 }

.setting-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    margin-bottom: 12px;
    color: var(--text-primary);
    gap: 8px;
}

.setting-label > span:first-child {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.setting-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    cursor: help;
    vertical-align: middle;
    flex-shrink: 0;
}

.setting-tooltip svg {
    color: var(--text-secondary);
    opacity: 0.6;
    transition: opacity 0.2s ease, color 0.2s ease;
    display: block;
}

.setting-tooltip:hover svg {
    opacity: 1;
    color: var(--blue-accent);
}

/* JavaScript-generated tooltip styles */
.tooltip-box {
    position: fixed;
    background-color: rgba(30, 41, 59, 0.95);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
    width: 280px;
    pointer-events: none;
    z-index: 10002;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    animation: tooltipFadeIn 0.15s ease-out;
}

.tooltip-arrow {
    position: fixed;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    pointer-events: none;
    z-index: 10002;
    animation: tooltipFadeIn 0.15s ease-out;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

 .slider-container {
     display: flex;
     align-items: center;
     gap: 16px;
 }

 .slider-container input[type="range"] {
     flex: 1;
     -webkit-appearance: none;
     appearance: none;
     height: 6px;
     background: var(--bg-hover);
     border-radius: 3px;
     outline: none;
 }

 .slider-container input[type="range"]::-webkit-slider-runnable-track {
     height: 6px;
     border-radius: 3px;
     background: linear-gradient(to right, var(--blue-accent) 0%, var(--blue-accent) var(--slider-value, 35%), var(--bg-hover) var(--slider-value, 35%), var(--bg-hover) 100%);
 }

 .slider-container input[type="range"]::-moz-range-track {
     height: 6px;
     border-radius: 3px;
     background: var(--bg-hover);
 }

 .slider-container input[type="range"]::-moz-range-progress {
     height: 6px;
     border-radius: 3px;
     background: var(--blue-accent);
 }

 .slider-container input[type="range"]::-webkit-slider-thumb {
     -webkit-appearance: none;
     appearance: none;
     width: 20px;
     height: 20px;
     background: var(--blue-accent);
     border-radius: 50%;
     cursor: pointer;
     transition: box-shadow 0.2s, background-color 0.2s;
     border: none;
     box-shadow: 0 0 0 1px rgba(3, 105, 161, 0.2);
     margin-top: -7px;
 }

 .slider-container input[type="range"]::-webkit-slider-thumb:hover {
     box-shadow: 0 0 0 6px rgba(3, 105, 161, 0.15);
     background-color: var(--gemini-blue);
 }

 .slider-container input[type="range"]::-moz-range-thumb {
     width: 20px;
     height: 20px;
     background: var(--blue-accent);
     border-radius: 50%;
     cursor: pointer;
     border: none;
     box-shadow: 0 0 0 1px rgba(3, 105, 161, 0.2);
     transition: box-shadow 0.2s, background-color 0.2s;
     margin-top: 0;
 }

 .slider-container input[type="range"]::-moz-range-thumb:hover {
     box-shadow: 0 0 0 6px rgba(3, 105, 161, 0.15);
     background-color: var(--gemini-blue);
 }

 .slider-container .value-box {
     width: 70px;
     text-align: center;
     border: none;
     border-radius: 8px;
     padding: 8px 4px;
     font-size: 14px;
     background-color: #ffffff;
     color: var(--text-primary);
     font-family: var(--font-family);
 }

/* Compact slider row for side-by-side label and slider */
.compact-slider-row {
    display: flex;
    align-items: center;
}

 .slider-container .value-box:focus {
     outline: none;
     border: none;
     box-shadow: none;
 }

 .toggle-switch {
     width: 44px;
     height: 24px;
     background-color: var(--bg-switch-inactive);
     border-radius: 12px;
     position: relative;
     cursor: pointer;
     border: 1px solid transparent;
     transition: background-color 0.2s;
 }

 .toggle-switch::after {
     content: '';
     position: absolute;
     width: 20px;
     height: 20px;
     background-color: #ffffff;
     border-radius: 50%;
     top: 1px;
     left: 2px;
     transition: transform 0.2s, background-color 0.2s;
     box-shadow: 0 2px 4px rgba(0,0,0,0.2);
 }

 .toggle-switch.active {
     background-color: var(--blue-accent);
     border-color: transparent;
 }

 .toggle-switch.active::after {
     transform: translateX(18px);
 }
 
.system-prompt-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-panel);
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--text-primary);
    resize: vertical;
    min-height: 160px;
    max-height: 400px;
    transition: border-color 0.2s;
}

.system-prompt-textarea:focus {
    outline: none;
    border-color: var(--blue-accent);
}

.system-prompt-textarea::placeholder {
    color: var(--text-secondary);
}

.save-default-prompt-btn {
    margin-top: 8px;
    margin-left: auto;
    padding: 6px 12px;
    background-color: transparent;
    color: var(--blue-accent);
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s;
    display: block;
}

.save-default-prompt-btn:hover {
    background-color: var(--bg-hover);
    color: #357abd;
}

.save-default-prompt-btn:active {
    transform: scale(0.98);
}

.save-default-prompt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

 select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-panel);
    font-family: var(--font-family);
    font-size: 15px;
    color: var(--text-primary);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
}

/* Hide welcome screen when messages exist */
.chat-messages > .message-wrapper ~ .welcome-screen,
.chat-messages > .welcome-screen:not(:first-child),
.chat-messages > .welcome-screen:not(:last-child) {
    display: none !important;
}

.welcome-screen h1 {
    font-size: 44px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.welcome-screen p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.status-badge.connected {
    background-color: #dcfce7;
    color: #166534;
}

.status-badge.disconnected {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-badge.connected .status-dot {
    background-color: #16a34a;
}

.status-badge.disconnected .status-dot {
    background-color: #dc2626;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-in;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-panel);
    margin: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-panel);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}

.modal-close:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Privacy Content Styles */
.privacy-content {
    font-family: var(--font-family);
    color: var(--text-primary);
    line-height: 1.7;
}

.privacy-section {
    margin-bottom: 28px;
}

.privacy-section:last-child {
    margin-bottom: 0;
}

.privacy-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--blue-accent);
    margin-bottom: 12px;
    line-height: 1.4;
}

.privacy-section p {
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.7;
}

.privacy-section p:last-child {
    margin-bottom: 0;
}

.privacy-section strong {
    font-weight: 600;
    color: var(--text-primary);
}

.privacy-footer {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 16px;
}

/* Authentication Overlay Styles */
#auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.auth-box {
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 48px 40px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease-out;
}

#auth-title {
    font-size: 28px;
    font-weight: 500;
    text-align: center;
    margin-bottom: 8px;
    margin-top: 0;
    color: var(--text-primary);
}

#auth-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
}

.google-btn {
    width: 100%;
    background: var(--blue-accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: background-color 0.2s, transform 0.1s;
    font-family: var(--font-family);
}

.google-btn:hover {
    background: var(--gemini-blue);
    transform: translateY(-1px);
}

.google-btn:active {
    transform: translateY(0);
}

.google-icon {
    flex-shrink: 0;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-divider span {
    padding: 0 16px;
}

/* Guest Ticket Section */
.guest-ticket-section {
    margin: 0;
}

.guest-ticket-toggle-btn {
    width: 100%;
    background: var(--bg-panel);
    color: var(--blue-accent);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.guest-ticket-toggle-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.guest-ticket-toggle-btn:active {
    transform: translateY(0);
}

.guest-ticket-toggle-btn svg {
    flex-shrink: 0;
}

.guest-ticket-input-container {
    margin-top: 16px;
    padding-top: 16px;
}

.guest-ticket-help {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 8px;
    line-height: 1.4;
}

.auth-input-group {
    position: relative;
    margin-bottom: 16px;
}

.auth-input-group .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.auth-input-group input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    font-family: var(--font-family);
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--bg-panel);
    color: var(--text-primary);
}

.auth-input-group input:focus {
    outline: none;
    border-color: var(--blue-accent);
    box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.1);
}

.email-auth-btn {
    width: 100%;
    background: var(--bg-button);
    color: var(--blue-accent);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    font-family: var(--font-family);
    margin-top: 8px;
}

.email-auth-btn:hover {
    background: var(--bg-button-hover);
    transform: translateY(-1px);
}

.email-auth-btn:active {
    transform: translateY(0);
}

.auth-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
}

.auth-switch {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.link-button {
    background: none;
    border: none;
    color: var(--blue-accent);
    cursor: pointer;
    font-weight: 500;
    font-family: var(--font-family);
    padding: 0;
    margin-left: 4px;
    text-decoration: none;
    transition: opacity 0.2s;
}

.link-button:hover {
    opacity: 0.8;
    text-decoration: underline;
}

#auth-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-hover);
    border-top-color: var(--blue-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Custom Dialog Styles */
.custom-dialog-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10001;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-in;
}

.custom-dialog-overlay.show {
    display: flex;
}

.custom-dialog-box {
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 32px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: dialogSlideUp 0.3s ease-out;
    text-align: center;
}

@keyframes dialogSlideUp {
    from {
        transform: translateY(30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.custom-dialog-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-icon {
    background: rgba(251, 191, 36, 0.15);
    color: #f59e0b;
}

.alert-icon svg {
    width: 32px;
    height: 32px;
    stroke: currentColor;
}

.confirm-icon {
    background: rgba(3, 105, 161, 0.15);
    color: var(--blue-accent);
}

.confirm-icon svg {
    width: 32px;
    height: 32px;
    stroke: currentColor;
}

.custom-dialog-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.custom-dialog-message {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 28px 0;
    white-space: pre-wrap;
}

.custom-dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.custom-dialog-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.custom-dialog-btn.primary-btn {
    background: var(--blue-accent);
    color: white;
}

.custom-dialog-btn.primary-btn:hover {
    background: var(--gemini-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(3, 105, 161, 0.3);
}

.custom-dialog-btn.primary-btn:active {
    transform: translateY(0);
}

.custom-dialog-btn.secondary-btn {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.custom-dialog-btn.secondary-btn:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.custom-dialog-btn.secondary-btn:active {
    transform: translateY(0);
}

/* Custom AI Modal Input Styles */
#customBotDialog input[type="text"]:focus,
#customBotDialog textarea:focus {
    border-color: #0369a1;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.08);
}

#customBotDialog input[type="text"]:hover,
#customBotDialog textarea:hover {
    border-color: #e0e0e0;
    background: #ffffff;
}

#customBotDialog select:focus {
    background: rgba(3, 105, 161, 0.02);
}

#customBotDialog select:hover {
    background: rgba(0, 0, 0, 0.02);
}

#customBotDialog input[type="text"]::placeholder,
#customBotDialog textarea::placeholder {
    color: #aaa;
}

/* Privacy Mode Banner */
.privacy-mode-banner {
    background: #f5f7fa;
    padding: 10px 24px;
    border-bottom: 1px solid #e2e8f0;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.privacy-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #64748b;
}

.privacy-banner-icon {
    flex-shrink: 0;
    color: #64748b;
}

.privacy-banner-text {
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0;
}

/* ============================================
   AI ARENA MODE STYLES
   ============================================ */

/* Arena Container */
.arena-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Arena Panels Grid */
.arena-panels {
    display: grid;
    grid-template-columns: 1fr 4px 1fr;
    gap: 0;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Individual Arena Panel */
.arena-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-main);
}

/* Arena Panel Header */
.arena-panel-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-bottom: none;
    background-color: transparent;
    min-height: 52px;
    position: relative;
}

.arena-panel-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex: 1;
}

.arena-panel-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.arena-model-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    padding: 4px 24px 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    max-width: 160px;
    outline: none;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 4px center;
    background-repeat: no-repeat;
    background-size: 14px;
}

.arena-model-select:hover {
    background-color: var(--bg-hover);
}

.arena-model-select:focus {
    background-color: var(--bg-hover);
    box-shadow: none;
}

/* Generating Indicator */
.arena-generating-indicator {
    font-size: 20px;
    color: var(--blue-accent);
    animation: blink 1s infinite;
    position: absolute;
    right: 20px;
}

.chat-generating-indicator {
    font-size: 16px;
    color: var(--blue-accent);
    animation: blink 1s infinite;
    margin-left: 12px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* Arena Divider */
.arena-divider {
    background-color: var(--border-color);
    cursor: col-resize;
    position: relative;
    transition: background-color 0.2s ease;
}

.arena-divider:hover {
    background-color: var(--blue-accent);
}

body.resizing-arena {
    cursor: col-resize;
    user-select: none;
}

body.resizing-arena * {
    cursor: col-resize !important;
    user-select: none !important;
}

/* Arena Chat Messages */
.arena-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Arena Input Containers */
.arena-input-container {
    padding: 4px 24px 24px 24px;
    background-color: transparent;
    flex-shrink: 0;
}

.arena-chat-messages .welcome-screen h2 {
    font-size: 24px;
    font-weight: 500;
}

/* Arena Settings Styles */
.arena-settings {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

#arenaSettings {
    margin-right: -24px;
    padding-right: 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.75) transparent;
}

#arenaSettings::-webkit-scrollbar {
    width: 7px;
}

#arenaSettings::-webkit-scrollbar-track {
    background: transparent;
}

#arenaSettings::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.75);
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.35);
}

#arenaSettings::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.95);
}

.arena-settings-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.6) transparent;
}

.arena-settings-container::-webkit-scrollbar {
    width: 6px;
}

.arena-settings-container::-webkit-scrollbar-track {
    background: transparent;
}

.arena-settings-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.25);
}

.arena-settings-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.85);
}

.arena-settings-section {
    padding: 0 0 24px 0;
    border-bottom: none;
    margin-top: 24px;
}

.arena-settings-section:first-child {
    margin-top: 32px;
}

.arena-settings-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.arena-settings-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 0;
    border-bottom: none;
}

.arena-card {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px !important;
    margin-top: 16px !important;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.arena-card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.arena-card .setting-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Responsive adjustments for Arena */
@media (max-width: 1200px) {
    .arena-panels {
        grid-template-columns: 1fr 3px 1fr;
    }
    
    .arena-panel-header {
        padding: 10px 16px;
    }
    
    .arena-model-select {
        min-width: 150px;
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .arena-panels {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 3px 1fr;
    }
    
    .arena-divider {
        cursor: row-resize;
    }
}

/* ============================================
   CUSTOMIZE AI MODE STYLES
   ============================================ */

/* Customize AI Container */
.customize-ai-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background-color: var(--bg-main);
}

/* Customize AI Header */
.customize-ai-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
    position: relative;
}

.customize-ai-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-align: center;
}

/* Add New AI Button */
.add-new-ai-btn {
    display: flex;
    align-items: center;
    position: absolute;
    right: 0;
    gap: 8px;
    padding: 10px 16px;
    background-color: var(--bg-button);
    color: var(--blue-accent);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-new-ai-btn:hover {
    background-color: var(--bg-button-hover);
    transform: translateY(-1px);
}

.add-new-ai-btn svg {
    flex-shrink: 0;
}

/* Section Container */
.customize-ai-section {
    margin-bottom: 40px;
}

/* Section Heading */
.customize-ai-section-heading {
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    opacity: 0.7;
}

/* Section Containers */
.custom-ai-section {
    margin-bottom: 40px;
}

.custom-ai-section:last-child {
    margin-bottom: 0;
}

.custom-ai-section-heading {
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

/* Cards Grid */
.custom-ai-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 24px;
}

.customize-ai-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 24px;
}

/* Individual Card */
.custom-ai-card {
    background: var(--bg-panel);
    border: none;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    max-width: 400px;
    min-height: 280px;
}

.custom-ai-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
}

/* Delete Button */
.custom-ai-delete-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #dc2626;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    padding: 0;
}

.custom-ai-delete-btn:hover {
    background: #fee2e2;
    transform: scale(1.15);
}

.custom-ai-delete-btn:active {
    background: #fecaca;
    transform: scale(0.95);
}

/* Card Content */
.custom-ai-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.custom-ai-title {
    font-size: 18px;
    font-weight: 600;
    color: #0369a1;
    margin: 0 0 8px 0;
    line-height: 1.4;
    text-align: center;
}

/* Model Info */
.custom-ai-model {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.custom-ai-model svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Description Section */
.custom-ai-description {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.custom-ai-description-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.custom-ai-description-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    opacity: 0.9;
    max-height: 150px;
    overflow-y: auto;
}

/* Card Actions */
.custom-ai-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 0;
}

.custom-ai-card-actions-left {
    display: flex;
    align-items: center;
}

.custom-ai-card-actions-right {
    display: flex;
    gap: 8px;
}

/* Privacy Indicator (Display Only) */
.custom-ai-privacy-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
}

.custom-ai-privacy-indicator svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.custom-ai-privacy-indicator span {
    font-weight: 500;
}

.custom-ai-action-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: transparent;
}

.custom-ai-action-btn:hover {
    transform: scale(1.1);
}

.custom-ai-action-btn.chat-btn {
    color: var(--blue-accent);
}

.custom-ai-action-btn.chat-btn:hover {
    background-color: var(--bg-button-hover);
}

.custom-ai-action-btn.edit-btn {
    color: var(--text-secondary);
}

.custom-ai-action-btn.edit-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.custom-ai-action-btn.share-btn {
    color: var(--text-secondary);
}

.custom-ai-action-btn.share-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.custom-ai-action-btn svg {
    flex-shrink: 0;
}

/* Responsive adjustments for Customize AI */
@media (max-width: 1200px) {
    .custom-ai-grid,
    .customize-ai-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    }
}

@media (max-width: 768px) {
    .customize-ai-container {
        padding: 16px;
    }
    
    .customize-ai-header h2 {
        font-size: 20px;
    }
    
    .customize-ai-section {
        margin-bottom: 32px;
    }
    
    .custom-ai-grid,
    .customize-ai-cards-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ============================================
   BOT CHAT MODE STYLES
   ============================================ */

/* Bot Chat Container */
.bot-chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Bot Chat Header (Deprecated - now using bot-info-message in chat) */
.bot-chat-header {
    display: none; /* Hidden - bot info is now shown as first message in chat */
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {
    /* Use viewport units that account for mobile browser chrome */
    body {
        height: 100dvh; /* Dynamic viewport height - adjusts when address bar hides */
        min-height: -webkit-fill-available;
    }

    .main-content {
        height: calc(100dvh - 16px);
        min-height: -webkit-fill-available;
        margin: 8px;
        flex: 1;
        width: auto;
    }

    /* Collapse sidebars by default on mobile */
    .left-sidebar.collapsed {
        width: 0;
        min-width: 0;
        padding: 0;
        opacity: 0;
        overflow: hidden;
        position: absolute;
        transform: translateX(-100%);
        pointer-events: none;
    }

    .sidebar-resize-handle {
        display: none;
    }

    .main-content #expandSidebarBtn {
        display: flex !important;
    }

    .right-sidebar.collapsed {
        width: 0;
        margin: 0;
        padding: 0;
        opacity: 0;
        overflow: hidden;
        position: absolute;
        right: 0;
        transform: translateX(100%);
        pointer-events: none;
    }

    #toggleSettingsBtn {
        display: flex !important;
    }

    /* When sidebars are manually expanded on mobile */
    .left-sidebar:not(.collapsed) {
        width: 240px;
        padding: 12px;
        opacity: 1;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1000;
        background-color: #ffffff;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
        transform: translateX(0);
        pointer-events: auto;
    }

    .right-sidebar:not(.collapsed) {
        width: 280px;
        padding: 16px;
        margin: 0;
        opacity: 1;
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 1000;
        background-color: var(--bg-panel);
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
        transform: translateX(0);
        pointer-events: auto;
    }

    #arenaSettings {
        margin-right: -16px;
        padding-right: 16px;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.75) transparent;
    }

    #arenaSettings::-webkit-scrollbar {
        width: 7px;
    }

    #arenaSettings::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.75);
        box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.35);
    }

    #arenaSettings::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.95);
    }

    /* Mobile overlay backdrop */
    body::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 999;
    }

    body:has(.left-sidebar:not(.collapsed))::after,
    body:has(.right-sidebar:not(.collapsed))::after {
        opacity: 1;
        pointer-events: auto;
    }

    /* Compact header to save space */
    .main-header {
        padding: 6px 12px;
        min-height: 44px;
    }

    /* Reduce icon button sizes */
    .icon-button {
        padding: 6px;
        width: 32px;
        height: 32px;
    }

    .icon-button svg {
        width: 16px;
        height: 16px;
        font-size: 16px;
    }

    .main-header-icons {
        gap: 4px;
    }

    /* Smaller model selector */
    .model-selector-header {
        margin: 0 6px;
    }

    .model-selector-header select {
        font-size: 14px;
        padding: 4px 20px 4px 6px;
        min-width: 110px;
        background-size: 14px;
    }

    /* More compact expand sidebar button */
    #expandSidebarBtn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }

    #expandSidebarBtn svg {
        width: 16px;
        height: 16px;
    }

    /* Reduce chat message padding */
    .chat-messages {
        padding: 12px;
        gap: 16px;
    }

    /* Avatar above bubble layout - completely vertical */
    .message-wrapper {
        max-width: 95%;
        width: 100%;
    }

    .message {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        width: 100%;
    }

    .message.user {
        flex-direction: column;
        align-items: flex-end;
    }

    .message.assistant {
        flex-direction: column;
        align-items: flex-start;
    }

    .message.thinking {
        flex-direction: column;
        align-items: flex-start;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 14px;
        align-self: flex-start;
    }

    .message.user .message-avatar {
        align-self: flex-end;
    }

    /* More compact message content - now truly full width */
    .message-content {
        padding: 8px 12px;
        border-radius: 12px; /* Less rounded */
        width: 100%;
        max-width: 100%;
        align-self: stretch;
    }

    .message-text {
        font-size: 15px;
        line-height: 1.5;
        width: 100%;
    }

    /* Adjust model label for vertical layout */
    .model-label {
        font-size: 11px;
        margin-bottom: 3px;
        margin-left: 0;
        width: 100%;
    }

    /* Compact input area - LESS ROUNDED */
    .chat-input-container {
        padding: 4px 12px 12px 12px;
    }

    .prompt-area {
        border-radius: 16px; /* Much less rounded than 28px */
        padding: 3px;
    }

    .prompt-input {
        padding: 8px 12px;
        font-size: 15px;
        border-radius: 16px;
        max-height: 120px;
    }

    /* Smaller button icons in prompt area */
    .prompt-buttons {
        gap: 4px;
        padding-right: 4px;
    }

    .prompt-buttons button {
        padding: 6px;
    }

    .attach-btn {
        padding: 6px !important;
    }

    .attach-btn svg {
        width: 16px;
        height: 16px;
    }

    /* More compact send button */
    .prompt-buttons .run-btn {
        padding: 6px 12px;
        border-radius: 12px;
        font-size: 13px;
        gap: 6px;
    }

    .prompt-buttons .run-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Compact attachments preview */
    .attachments-preview {
        padding: 8px;
        gap: 6px;
        margin-bottom: 6px;
        border-radius: 8px;
    }

    .attachment-item {
        padding: 6px 10px;
        gap: 6px;
        border-radius: 6px;
        font-size: 12px;
        max-width: 160px;
    }

    .attachment-item img.attachment-thumbnail {
        width: 24px;
        height: 24px;
    }

    .attachment-item .attachment-icon {
        width: 24px;
        height: 24px;
    }

    /* Compact queue indicator */
    .queued-message-indicator {
        padding: 8px 12px;
        margin: 0 12px 6px 12px;
        gap: 10px;
        border-radius: 12px;
    }
    
    .queued-label {
        font-size: 12px;
    }
    
    .queued-preview {
        font-size: 12px;
    }
    
    .clear-queue-btn {
        width: 20px;
        height: 20px;
    }
    
    .clear-queue-btn svg {
        width: 11px;
        height: 11px;
    }

    /* Reduce welcome screen size and ensure proper behavior */
    .welcome-screen {
        position: static;
        height: auto;
        min-height: 0;
        flex: none;
    }

    .welcome-screen h1 {
        font-size: 28px;
        margin-bottom: 12px;
    }

    .welcome-screen p {
        font-size: 14px;
        margin-bottom: 20px;
    }

    .status-badge {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* Align chat messages to top on mobile (not centered) */
    .chat-messages {
        justify-content: flex-start;
        align-items: stretch;
    }

    /* Only center when welcome screen is the only element */
    .chat-messages:empty,
    .chat-messages > .welcome-screen:first-child:last-child {
        justify-content: center;
    }

    /* Ensure welcome screen is hidden when messages exist */
    .chat-messages > .message-wrapper ~ .welcome-screen,
    .chat-messages > .welcome-screen:not(:first-child),
    .chat-messages > .welcome-screen:not(:last-child) {
        display: none !important;
    }

    /* Compact arena mode */
    .arena-panel-header {
        padding: 8px 12px;
        min-height: 44px;
    }

    .arena-panel-label {
        font-size: 12px;
    }

    .arena-model-select {
        font-size: 13px;
        padding: 4px 20px 4px 6px;
        max-width: 120px;
    }

    .arena-chat-messages {
        padding: 12px;
    }

    .arena-chat-messages .welcome-screen h2 {
        font-size: 20px;
    }

    .arena-input-container {
        padding: 4px 12px 12px 12px;
    }

    /* Compact code blocks */
    .message-text .code-container pre {
        padding: 2em 0.75em 0.75em 0.75em;
        max-height: 300px;
        font-size: 0.85em;
    }

    .message-text .code-header {
        padding: 6px 12px;
    }

    .message-text .language-name {
        font-size: 0.7em;
    }

    .message-text .copy-code-button {
        padding: 3px 8px;
        font-size: 0.7em;
    }

    .message-text .copy-table-button {
        padding: 3px 8px;
        font-size: 0.7em;
    }

    .message-text .table-header {
        padding: 6px 12px;
    }

    .message-text .table-label {
        font-size: 0.7em;
    }

    /* Compact message actions */
    .message-actions {
        gap: 6px;
        margin-top: 6px;
        padding-top: 6px;
    }

    .message-action-btn {
        padding: 3px 6px;
        font-size: 12px;
        gap: 3px;
    }

    .message-action-btn svg {
        width: 12px;
        height: 12px;
    }

    /* Compact thinking blocks */
    .thinking-header {
        gap: 6px;
        margin-bottom: 6px;
        font-size: 13px;
    }

    .thinking-icon {
        width: 14px;
        height: 14px;
    }

    .thinking-content {
        max-height: 300px;
        font-size: 13px;
    }

    /* Compact tables */
    .message-text table {
        font-size: 0.85em;
        margin: 0.75em 0;
    }

    .message-text th,
    .message-text td {
        padding: 8px 10px;
    }

    /* Compact headings */
    .message-text h1 { font-size: 1.3em; }
    .message-text h2 { font-size: 1.2em; }
    .message-text h3 { font-size: 1.1em; }

    .message-text h1,
    .message-text h2,
    .message-text h3,
    .message-text h4,
    .message-text h5,
    .message-text h6 {
        margin-top: 1.5em;
        margin-bottom: 0.6em;
    }

    /* Compact lists */
    .message-text ul,
    .message-text ol {
        padding-left: 20px;
        margin-top: 0.75em;
        margin-bottom: 0.75em;
    }

    .message-text li {
        margin-bottom: 0.4em;
        padding-left: 6px;
    }

    /* Compact privacy banner */
    .privacy-mode-banner {
        padding: 6px 12px;
    }

    .privacy-banner-text {
        font-size: 13px;
    }

    .privacy-banner-icon {
        width: 16px;
        height: 16px;
    }

    /* Sidebar content styling when expanded */
    .left-sidebar:not(.collapsed) .logo {
        font-size: 18px;
        padding: 6px 0;
    }

    .left-sidebar:not(.collapsed) .collapse-sidebar-btn {
        width: 28px;
        height: 28px;
    }

    .left-sidebar:not(.collapsed) .nav-item {
        padding: 10px 12px;
        font-size: 14px;
        margin-bottom: 6px;
    }

    .left-sidebar:not(.collapsed) .nav-item svg {
        width: 18px;
        height: 18px;
        margin-right: 12px;
    }

    .left-sidebar:not(.collapsed) .history {
        margin-top: 20px;
    }

    .left-sidebar:not(.collapsed) .history-item {
        padding: 6px 12px;
        font-size: 13px;
        gap: 6px;
    }

    .left-sidebar:not(.collapsed) .sidebar-footer {
        padding: 12px 0;
        font-size: 12px;
    }

    .left-sidebar:not(.collapsed) .privacy-mode-container {
        padding: 8px 12px;
        margin-bottom: 10px;
    }

    .left-sidebar:not(.collapsed) .privacy-mode-label {
        font-size: 13px;
        gap: 6px;
    }

    .left-sidebar:not(.collapsed) .sidebar-footer-links a {
        font-size: 13px;
        padding: 6px 0 6px 12px;
        gap: 6px;
    }

    /* Right sidebar content styling when expanded */
    .right-sidebar:not(.collapsed) .settings-header {
        margin-bottom: 16px;
    }

    .right-sidebar:not(.collapsed) .settings-header h2 {
        font-size: 14px;
    }

    .right-sidebar:not(.collapsed) .setting-group {
        padding-bottom: 24px;
        margin-top: 24px;
    }

    .right-sidebar:not(.collapsed) .setting-item {
        margin-bottom: 18px;
    }

    .right-sidebar:not(.collapsed) .setting-label {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .right-sidebar:not(.collapsed) .slider-container {
        gap: 12px;
    }

    .right-sidebar:not(.collapsed) .slider-container .value-box {
        width: 60px;
        padding: 6px 4px;
        font-size: 13px;
    }

    .right-sidebar:not(.collapsed) select {
        padding: 8px 12px;
        font-size: 14px;
        padding-right: 32px;
    }

    /* Compact auth overlay */
    .auth-box {
        padding: 32px 24px;
        width: 95%;
    }

    #auth-title {
        font-size: 24px;
        margin-bottom: 6px;
    }

    #auth-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .google-btn,
    .email-auth-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .auth-input-group {
        margin-bottom: 12px;
    }

    .auth-input-group input {
        padding: 10px 12px 10px 40px;
        font-size: 14px;
    }

    .auth-divider {
        margin: 20px 0;
        font-size: 12px;
    }

    .auth-switch {
        margin-top: 20px;
        font-size: 13px;
    }

    /* Compact modals */
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-body {
        padding: 20px;
    }

    .privacy-section h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .privacy-section p {
        font-size: 14px;
        margin-bottom: 10px;
    }

    /* Compact custom dialogs */
    .custom-dialog-box {
        padding: 24px;
        width: 95%;
    }

    .custom-dialog-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 16px;
    }

    .alert-icon svg,
    .confirm-icon svg {
        width: 28px;
        height: 28px;
    }

    .custom-dialog-title {
        font-size: 20px;
        margin-bottom: 10px;
    }

    .custom-dialog-message {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .custom-dialog-btn {
        padding: 8px 20px;
        font-size: 14px;
        min-width: 90px;
    }
    
    
    /* Compact follow-up badge in input area on mobile */
    .follow-up-badge-container {
        padding: 4px 6px 6px 6px;
        width: calc(100% - 4px);
        margin: 0 2px;
    }
    
    .follow-up-badge {
        padding: 6px 10px;
        gap: 8px;
        border-radius: 12px;
        min-height: 32px;
    }
    
    .follow-up-badge-text {
        font-size: 12px;
    }
    
    .follow-up-badge-remove {
        width: 20px;
        height: 20px;
    }
    
    .follow-up-badge-remove svg {
        width: 11px;
        height: 11px;
    }
    
    /* Compact follow-up context in message bubbles on mobile */
    .follow-up-context {
        padding: 8px 10px;
        font-size: 12px;
        border-radius: 12px;
    }
    
    .follow-up-context-text {
        font-size: 12px;
    }
    
    .follow-up-badge-text {
        font-size: 12px;
    }
}

/* Extra optimizations for very small screens */
@media (max-width: 480px) {
    /* Even more compact header */
    .main-header {
        padding: 4px 8px;
        min-height: 40px;
    }

    .icon-button {
        padding: 5px;
        width: 28px;
        height: 28px;
    }

    .icon-button svg {
        width: 14px;
        height: 14px;
    }

    .main-header-icons {
        gap: 2px;
    }

    .model-selector-header {
        margin: 0 4px;
    }

    .model-selector-header select {
        font-size: 13px;
        padding: 3px 18px 3px 4px;
        min-width: 100px;
    }

    /* Ultra compact input */
    .chat-input-container {
        padding: 3px 8px 8px 8px;
    }

    .prompt-area {
        border-radius: 14px;
        padding: 2px;
    }

    .prompt-input {
        padding: 6px 10px;
        font-size: 14px;
        border-radius: 14px;
    }

    .prompt-buttons .run-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    /* Ultra compact follow-up badge */
    .follow-up-badge-container {
        padding: 3px 4px 5px 4px;
        width: calc(100% - 2px);
        margin: 0 1px;
    }
    
    .follow-up-badge {
        padding: 5px 8px;
        gap: 6px;
        border-radius: 10px;
        min-height: 28px;
    }
    
    .follow-up-badge-text {
        font-size: 11px;
    }
    
    .follow-up-badge-remove {
        width: 18px;
        height: 18px;
    }
    
    .follow-up-badge-remove svg {
        width: 10px;
        height: 10px;
    }
    
    /* Ultra compact queue indicator */
    .queued-message-indicator {
        padding: 6px 10px;
        margin: 0 8px 4px 8px;
        gap: 8px;
        border-radius: 10px;
    }
    
    .queued-label {
        font-size: 11px;
    }
    
    .queued-preview {
        font-size: 11px;
    }
    
    .clear-queue-btn {
        width: 18px;
        height: 18px;
    }
    
    .clear-queue-btn svg {
        width: 10px;
        height: 10px;
    }
    
    /* Ultra compact follow-up context in message bubbles */
    .follow-up-context {
        padding: 6px 8px;
        font-size: 11px;
        border-radius: 10px;
    }
    
    .follow-up-context-text {
        font-size: 11px;
    }

    /* Tighter message spacing */
    .chat-messages {
        padding: 8px;
        gap: 12px;
    }

    /* Avatar above bubble - extra compact */
    .message-wrapper {
        max-width: 98%;
        width: 100%;
    }

    .message {
        gap: 5px;
        width: 100%;
    }

    .message-content {
        padding: 6px 10px;
        border-radius: 10px;
        width: 100%;
        max-width: 100%;
        align-self: stretch;
    }

    .message-text {
        font-size: 14px;
        width: 100%;
    }

    /* Ultra compact avatar */
    .message-avatar {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }

    .model-label {
        margin-left: 0;
        font-size: 10px;
        width: 100%;
    }

    /* Smaller welcome screen */
    .welcome-screen {
        position: static;
        height: auto;
        min-height: 0;
        flex: none;
    }

    .welcome-screen h1 {
        font-size: 24px;
    }

    .welcome-screen p {
        font-size: 13px;
    }
}

/* Landscape mobile optimization */
@media (max-height: 500px) and (orientation: landscape) {
    /* Minimize vertical spacing in landscape */
    .main-header {
        padding: 4px 12px;
        min-height: 36px;
    }

    .chat-messages {
        padding: 8px 12px;
        gap: 12px;
    }

    .chat-input-container {
        padding: 3px 12px 8px 12px;
    }

    .prompt-input {
        max-height: 80px;
    }

    .message-content {
        padding: 6px 10px;
    }

    .welcome-screen {
        padding: 12px;
        position: static;
        height: auto;
        min-height: 0;
        flex: none;
    }

    .welcome-screen h1 {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .welcome-screen p {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .arena-panel-header {
        padding: 6px 12px;
        min-height: 36px;
    }
}

/* ============================================
   TEXT SELECTION CONTEXT MENU
   ============================================ */

.text-selection-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px;
    z-index: 10000;
    display: none;
    min-width: 120px;
}

.text-selection-menu.show {
    display: block;
    animation: menuFadeIn 0.15s ease-out;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.text-selection-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-primary);
    transition: background-color 0.15s;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-family);
}

.text-selection-menu-item:hover {
    background-color: var(--bg-hover);
}

.text-selection-menu-item:active {
    background-color: var(--bg-button);
}

.text-selection-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
}

/* Follow-up context badge in input area - full width banner with quotation marks */
.follow-up-badge-container {
    padding: 6px 10px 8px 10px;
    width: calc(100% - 8px);
    margin: 0 4px;
}

.follow-up-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f1f5f9;
    border: none;
    border-radius: 16px;
    padding: 8px 14px;
    width: 100%;
    min-height: 36px;
    animation: badgeSlideIn 0.3s ease-out;
    overflow: hidden;
}

@keyframes badgeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.follow-up-badge-text {
    flex: 1;
    font-size: 13px;
    color: #64748b;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.5;
    min-width: 0;
}

.follow-up-badge-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    color: #94a3b8;
}

.follow-up-badge-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.follow-up-badge-remove svg {
    width: 13px;
    height: 13px;
}

/* Follow-up context badge in message bubbles - full width banner with quotation marks */
.follow-up-context {
    display: block;
    background: #f1f5f9;
    border: none;
    padding: 10px 14px;
    margin: 0 0 12px 0;
    border-radius: 14px;
    font-size: 13px;
    color: #64748b;
    font-style: italic;
    word-break: break-word;
    width: 100%;
    overflow-wrap: break-word;
    line-height: 1.5;
}

.follow-up-context-text {
    color: #64748b;
    font-style: italic;
    line-height: 1.5;
    display: block;
    word-break: break-word;
    overflow-wrap: break-word;
    width: 100%;
}

/* Follow-up context in user messages - slightly lighter for contrast */
.message.user .follow-up-context {
    background: rgba(255, 255, 255, 0.25);
    border: none;
}

.message.user .follow-up-context-text {
    color: rgba(255, 255, 255, 0.95);
}

/* ============================================
   SCROLL NAVIGATION CONTROLS
   ============================================ */

.scroll-controls {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
    max-width: 44px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.scroll-controls.active {
    opacity: 1;
    pointer-events: auto;
}

.scroll-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    color: var(--text-secondary);
    opacity: 0;
    transform: scale(0.7);
    pointer-events: none;
}

.scroll-controls.active .scroll-btn.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.scroll-btn.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.scroll-btn:hover:not(:disabled) {
    background: rgba(239, 246, 255, 0.7);
    color: var(--blue-accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--blue-accent);
}

.scroll-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.scroll-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.scroll-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Icon styles - icons are already oriented correctly */

/* Mobile adjustments */
@media (max-width: 768px) {
    .scroll-controls {
        right: 8px;
        gap: 6px;
        /* Prevent horizontal overflow */
        max-width: calc(100vw - 16px);
    }

    .scroll-btn {
        width: 36px;
        height: 36px;
    }

    .scroll-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .main-content {
        overflow-x: hidden;
    }
}

@media (max-width: 480px) {
    .scroll-controls {
        right: 4px;
        gap: 4px;
        /* Prevent horizontal overflow */
        max-width: calc(100vw - 8px);
    }

    .scroll-btn {
        width: 32px;
        height: 32px;
    }

    .scroll-btn svg {
        width: 16px;
        height: 16px;
    }
}


