* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    /* Disable text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Disable dragging */
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    /* Disable context menu */
    -webkit-touch-callout: none;
}

:root {
    /* Dark Theme (Default) */
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --input-bg: #151515;
    --message-user-bg: #1a1a1a;
    --message-ai-bg: #121212;
    --border-radius: 16px;
}

/* Light Theme */
body.light-theme,
html.light-theme-early {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #1a1a1a;
    --text-secondary: #6c757d;
    --input-bg: #ffffff;
    --message-user-bg: #e3f2fd;
    --message-ai-bg: #f5f5f5;
}

/* Light theme specific adjustments */
body.light-theme .sidebar {
    border-right: 1px solid #e9ecef;
}

body.light-theme .message-input {
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body.light-theme .message-input:focus {
    background: #ffffff;
    border-color: #6e8efb;
    box-shadow: 0 0 0 3px rgba(110, 142, 251, 0.1);
}

body.light-theme .new-chat-btn:hover,
body.light-theme .history-item:hover,
body.light-theme .user-section:hover {
    background: rgba(110, 142, 251, 0.08);
}

body.light-theme .history-item.active {
    background: rgba(110, 142, 251, 0.15);
}

body.light-theme .setting-item:hover {
    background: rgba(110, 142, 251, 0.03);
}

body.light-theme .setting-icon {
    background: rgba(110, 142, 251, 0.1);
}

body.light-theme .settings-close:hover {
    background: rgba(110, 142, 251, 0.08);
    color: var(--text-primary);
}

body.light-theme .new-chat-header-btn:hover {
    background: rgba(110, 142, 251, 0.08);
}

body.light-theme .new-chat-header-btn:active {
    background: rgba(110, 142, 251, 0.12);
}

body.light-theme .send-button {
    background: var(--text-primary);
    color: var(--bg-primary);
}

body.light-theme .send-button:hover {
    background: #333333;
    color: #ffffff;
}

body.light-theme .suggestion-card:hover {
    background: rgba(110, 142, 251, 0.05);
    border-color: rgba(110, 142, 251, 0.3);
    box-shadow: 0 8px 32px rgba(110, 142, 251, 0.15);
}

body.light-theme .mobile-backdrop {
    background: rgba(0, 0, 0, 0.3);
}

body.light-theme .settings-menu {
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

body.light-theme .toggle-switch {
    background: #e9ecef;
    border: 1px solid #dee2e6;
}

body.light-theme .toggle-switch.active {
    background: linear-gradient(-45deg, #6e8efb, #a777e3, #6e8efb, #a777e3);
    background-size: 400% 400%;
    animation: fluidGradient 8s ease infinite;
    border: none;
}

body.light-theme .toggle-switch .toggle-thumb {
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

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

/* Subtle background light effect */
body::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.03) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    z-index: -1;
    filter: blur(40px);
    pointer-events: none;
}

/* Light theme version - slightly grey light */
body.light-theme::before {
    background: radial-gradient(circle, rgba(0, 0, 0, 0.02) 0%, transparent 70%);
    filter: blur(60px);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.logo-container {
    padding: 24px 20px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-dot {
    color: var(--text-primary);
}

.new-chat-btn {
    margin: 12px 16px;
    padding: 14px;
    background: var(--input-bg);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-weight: 500;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.history {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.history-item {
    padding: 14px 16px;
    margin: 0 12px 8px;
    border-radius: var(--border-radius);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.2s ease;
}

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

.history-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.user-section {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 12px;
    margin: 8px;
    position: relative;
    overflow: hidden;
}

.user-section:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.user-section:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.08);
}

.user-info {
    flex: 1;
    text-align: left;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-hint {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.user-section:hover .settings-hint {
    opacity: 1;
}

.settings-icon {
    opacity: 0.6;
    transition: all 0.2s ease;
    font-size: 14px;
}

.user-section:hover .settings-icon {
    opacity: 1;
    transform: rotate(90deg);
}

/* Settings Menu */
.settings-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 260px;
    height: 0;
    background: var(--bg-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.settings-menu.open {
    height: 60vh;
}

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

.settings-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.settings-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.settings-content {
    padding: 8px 0;
    overflow-y: auto;
    height: calc(100% - 73px);
}

.setting-item {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: background 0.2s ease;
    cursor: pointer;
}

.setting-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.setting-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 14px;
}

.setting-text {
    flex: 1;
}

.setting-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.setting-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.toggle-switch {
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-switch.active {
    background: linear-gradient(-45deg, #6e8efb, #a777e3, #6e8efb, #a777e3);
    background-size: 400% 400%;
    animation: fluidGradient 8s ease infinite;
    will-change: background-position;
}

.toggle-thumb {
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active .toggle-thumb {
    transform: translateX(18px);
}

.action-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn.danger {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
}

.action-btn.danger:hover {
    background: rgba(255, 59, 48, 0.2);
    transform: translateY(-1px);
}

/* Settings menu backdrop */
.settings-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.settings-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(-45deg, #6e8efb, #a777e3, #23a6d5, #23d5ab, #6e8efb, #a777e3);
    background-size: 600% 600%;
    animation: fluidGradientSlow 12s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 14px;
    will-change: background-position;
}

/* Main Chat Area */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
}

/* Empty Chat Welcome Screen */
.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
    animation: fadeInContent 0.3s ease-out;
}

.empty-chat.fade-out {
    animation: fadeOutContent 0.2s ease-out forwards;
}

.welcome-section {
    margin-bottom: 60px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: 24px;
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab, #6e8efb, #a777e3);
    background-size: 500% 500%;
    animation: fluidGradient 15s ease infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 32px;
    font-size: 36px;
    color: white;
    box-shadow: 0 8px 32px rgba(110, 142, 251, 0.3);
    will-change: background-position;
    transform: translateZ(0);
}

.welcome-title {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -1px;
}

.welcome-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 500px;
    margin: 0 auto;
}

.prompt-suggestions {
    width: 100%;
}

.suggestions-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 32px;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.suggestion-card {
    background: var(--input-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    text-align: left;
}

.suggestion-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    border-color: rgba(110, 142, 251, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.suggestion-card:active {
    transform: translateY(0);
}

.suggestion-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(110, 142, 251, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #6e8efb;
    margin-bottom: 16px;
}

.suggestion-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.suggestion-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.chat-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
}

/* Version Switcher */
.version-switcher-container {
    position: fixed;
    top: calc(20px + env(safe-area-inset-top));
    left: calc(260px + (100vw - 260px) / 2);
    transform: translateX(-50%);
    z-index: 5;
}

.version-switcher-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    -webkit-tap-highlight-color: transparent;
    width: 140px;
}

.version-switcher-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.version-switcher-btn i {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.version-switcher-btn.open i {
    transform: rotate(180deg);
}

.version-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: rgba(26, 26, 26, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    min-width: 200px;
}

.version-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.version-dropdown-content {
    max-height: 300px;
    overflow-y: auto;
}

.version-option {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.version-option:last-child {
    border-bottom: none;
}

.version-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.version-option.active {
    background: rgba(110, 142, 251, 0.1);
    border-left: 3px solid #6e8efb;
}

.version-option-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.version-option-id {
    font-size: 12px;
    color: var(--text-secondary);
}

.version-option.active .version-option-name {
    color: #6e8efb;
}

/* Light theme */
body.light-theme .version-switcher-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

body.light-theme .version-switcher-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
}

body.light-theme .version-dropdown {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

body.light-theme .version-option {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-theme .version-option:hover {
    background: rgba(0, 0, 0, 0.03);
}

body.light-theme .version-option.active {
    background: rgba(110, 142, 251, 0.08);
}

.new-chat-header-btn {
    position: fixed;
    top: calc(20px + env(safe-area-inset-top));
    right: calc(20px + env(safe-area-inset-right));
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
    z-index: 4;
    -webkit-tap-highlight-color: transparent;
}

.new-chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.05);
}

.new-chat-header-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.12);
}

.chat-title {
    font-size: 20px;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
    min-width: 0;
}

.chat-messages-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.chat-messages-content.fade-in {
    animation: fadeInContent 0.3s ease-out;
}

.chat-messages-content.fade-out {
    animation: fadeOutContent 0.2s ease-out forwards;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    cursor: pointer;
    min-width: 0;
    overflow-x: hidden;
}

.message:hover {
    opacity: 0.95;
}
    
.message-content {
    padding: 20px 24px;
    border-radius: var(--border-radius);
    line-height: 1.6;
    font-size: 16px;
    word-break: break-word;
    transition: opacity 120ms ease;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.user .message-content {
    background: transparent;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    text-align: right;
}

/* Message header for AI messages */
.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 0 24px;
}

.message-version {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    opacity: 0.7;
    letter-spacing: 0.5px;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.6;
}

body.light-theme .message-version,
body.light-theme .message-time {
    color: #57606a;
}

.ai .message-content {
    background: transparent;    
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Markdown Styling */
.message-content code.inline-code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 14px;
    color: #ff79c6;
}

body.light-theme .message-content code.inline-code {
    background: rgba(0, 0, 0, 0.06);
    color: #d63384;
}

.message-content .code-block-wrapper {
    margin: 12px 0 12px 0;
    border-radius: 8px;
    background: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

body.light-theme .message-content .code-block-wrapper {
    background: #f6f8fa;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.message-content .code-block-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

body.light-theme .message-content .code-block-header {
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.message-content .code-block-language {
    font-size: 11px;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
}

body.light-theme .message-content .code-block-language {
    color: #57606a;
}

.message-content .copy-code-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #8b949e;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    outline: none;
}

.message-content .copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.message-content .copy-code-btn:focus {
    outline: none;
    border: none;
}

.message-content .copy-code-btn.copied {
    background: rgba(110, 142, 251, 0.2);
    color: #6e8efb;
}

body.light-theme .message-content .copy-code-btn {
    background: rgba(0, 0, 0, 0.04);
    border: none;
    color: #57606a;
}

body.light-theme .message-content .copy-code-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #24292f;
}

body.light-theme .message-content .copy-code-btn.copied {
    background: rgba(110, 142, 251, 0.15);
    color: #5a7ce8;
}

/* Mermaid diagram styles */
.message-content .mermaid-wrapper .code-block-header {
    justify-content: space-between;
}

.message-content .mermaid-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.message-content .mermaid-toggle-btn {
    background: rgba(110, 142, 251, 0.15);
    border: none;
    color: #6e8efb;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    outline: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-content .mermaid-toggle-btn:hover {
    background: rgba(110, 142, 251, 0.25);
    color: #8ba4fc;
}

.message-content .mermaid-toggle-btn:focus {
    outline: none;
    border: none;
}

.message-content .mermaid-toggle-btn i {
    font-size: 10px;
}

body.light-theme .message-content .mermaid-toggle-btn {
    background: rgba(110, 142, 251, 0.1);
    color: #5a7ce8;
}

body.light-theme .message-content .mermaid-toggle-btn:hover {
    background: rgba(110, 142, 251, 0.2);
    color: #4a6cd8;
}

.message-content .mermaid-diagram-view {
    padding: 24px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

body.light-theme .message-content .mermaid-diagram-view {
    background: rgba(0, 0, 0, 0.02);
}

.message-content .mermaid-container {
    max-width: 100%;
    overflow-x: auto;
}

.message-content .mermaid-container svg {
    max-width: 100%;
    height: auto;
}

.message-content pre {
    margin: 0;
    padding: 16px;
    overflow: visible;
    background: transparent !important;
}

/* Custom scrollbar for code blocks */
.message-content .code-block-wrapper::-webkit-scrollbar {
    height: 8px;
}

.message-content .code-block-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0 0 8px 8px;
}

.message-content .code-block-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.message-content .code-block-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

body.light-theme .message-content .code-block-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

body.light-theme .message-content .code-block-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

body.light-theme .message-content .code-block-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.message-content pre code {
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0;
    font-size: 14px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    display: block;
    white-space: pre;
    color: inherit;
    text-shadow: none;
}

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

.message-content em {
    font-style: italic;
}

.message-content strong em,
.message-content em strong {
    font-weight: 600;
    font-style: italic;
}

/* Markdown Headings */
.message-content h1.markdown-heading,
.message-content h2.markdown-heading,
.message-content h3.markdown-heading,
.message-content h4.markdown-heading,
.message-content h5.markdown-heading,
.message-content h6.markdown-heading {
    color: var(--text-primary);
    font-weight: 700;
    margin: 20px 0 12px 0;
    line-height: 1.3;
}

.message-content h1.markdown-heading { font-size: 28px; margin-top: 24px; }
.message-content h2.markdown-heading { font-size: 24px; margin-top: 20px; }
.message-content h3.markdown-heading { font-size: 20px; }
.message-content h4.markdown-heading { font-size: 18px; }
.message-content h5.markdown-heading { font-size: 16px; }
.message-content h6.markdown-heading { font-size: 14px; }

/* Markdown Lists */
.message-content ul.markdown-list,
.message-content ol.markdown-list {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content ul.markdown-list {
    list-style-type: disc;
}

.message-content ol.markdown-list {
    list-style-type: decimal;
}

.message-content ul.markdown-list li,
.message-content ol.markdown-list li {
    margin: 6px 0;
    line-height: 1.6;
    color: var(--text-primary);
}

.message-content ul.markdown-list li::marker,
.message-content ol.markdown-list li::marker {
    color: var(--text-secondary);
}

/* Nested lists */
.message-content ul.markdown-list ul.markdown-list,
.message-content ul.markdown-list ol.markdown-list,
.message-content ol.markdown-list ul.markdown-list,
.message-content ol.markdown-list ol.markdown-list {
    margin: 4px 0;
    padding-left: 20px;
}

.message-content ul.markdown-list ul.markdown-list {
    list-style-type: circle;
}

.message-content ul.markdown-list ul.markdown-list ul.markdown-list {
    list-style-type: square;
}

body.light-theme .message-content ul.markdown-list li::marker,
body.light-theme .message-content ol.markdown-list li::marker {
    color: #6c757d;
}

/* Task Lists */
.message-content ul.task-list {
    list-style: none;
    margin: 12px 0;
    padding-left: 0;
}

.message-content li.task-list-item {
    list-style: none;
    margin: 8px 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.message-content li.task-list-item input[type="checkbox"] {
    margin-top: 4px;
    cursor: default;
    accent-color: #6e8efb;
    flex-shrink: 0;
}

body.light-theme .message-content li.task-list-item input[type="checkbox"] {
    accent-color: #5a7ce8;
}

/* Blockquotes */
.message-content blockquote.markdown-blockquote {
    margin: 16px 0;
    padding: 12px 16px;
    border-left: 4px solid #6e8efb;
    background: rgba(110, 142, 251, 0.1);
    border-radius: 4px;
    color: var(--text-primary);
    font-style: italic;
}

body.light-theme .message-content blockquote.markdown-blockquote {
    border-left-color: #5a7ce8;
    background: rgba(90, 124, 232, 0.08);
    color: #495057;
}

/* Markdown Links */
.message-content a.markdown-link {
    color: #6e8efb;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.message-content a.markdown-link:hover {
    border-bottom-color: #6e8efb;
}

body.light-theme .message-content a.markdown-link {
    color: #5a7ce8;
}

body.light-theme .message-content a.markdown-link:hover {
    border-bottom-color: #5a7ce8;
}

/* Markdown Images */
.message-content img.markdown-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
    display: block;
}

/* Markdown Tables */
.message-content table.markdown-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-content table.markdown-table th,
.message-content table.markdown-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.message-content table.markdown-table th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: var(--text-primary);
}

.message-content table.markdown-table td {
    color: var(--text-primary);
}

.message-content table.markdown-table tr:last-child td {
    border-bottom: none;
}

.message-content table.markdown-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

body.light-theme .message-content table.markdown-table {
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.light-theme .message-content table.markdown-table th,
body.light-theme .message-content table.markdown-table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.light-theme .message-content table.markdown-table th {
    background: rgba(0, 0, 0, 0.03);
}

body.light-theme .message-content table.markdown-table tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

/* Prism theme overrides for dark mode */
.message-content pre[class*="language-"] {
    background: transparent !important;
    margin: 0;
    padding: 16px;
}

.message-content code[class*="language-"] {
    background: transparent !important;
    color: #ccc;
    text-shadow: none;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #7c7c7c;
}

.token.punctuation {
    color: #ccc;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
    color: #f07178;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #c3e88d;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: #89ddff;
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: #c792ea;
}

.token.function,
.token.class-name {
    color: #82aaff;
}

.token.regex,
.token.important,
.token.variable {
    color: #f07178;
}

/* Light theme syntax highlighting */
body.light-theme .message-content code[class*="language-"] {
    color: #24292e;
}

body.light-theme .token.comment,
body.light-theme .token.prolog,
body.light-theme .token.doctype,
body.light-theme .token.cdata {
    color: #6a737d;
}

body.light-theme .token.punctuation {
    color: #24292e;
}

body.light-theme .token.property,
body.light-theme .token.tag,
body.light-theme .token.boolean,
body.light-theme .token.number,
body.light-theme .token.constant,
body.light-theme .token.symbol,
body.light-theme .token.deleted {
    color: #d73a49;
}

body.light-theme .token.selector,
body.light-theme .token.attr-name,
body.light-theme .token.string,
body.light-theme .token.char,
body.light-theme .token.builtin,
body.light-theme .token.inserted {
    color: #22863a;
}

body.light-theme .token.operator,
body.light-theme .token.entity,
body.light-theme .token.url,
body.light-theme .language-css .token.string,
body.light-theme .style .token.string {
    color: #005cc5;
}

body.light-theme .token.atrule,
body.light-theme .token.attr-value,
body.light-theme .token.keyword {
    color: #d73a49;
}

body.light-theme .token.function,
body.light-theme .token.class-name {
    color: #6f42c1;
}

body.light-theme .token.regex,
body.light-theme .token.important,
body.light-theme .token.variable {
    color: #e36209;
}

/* Message Edit Mode */
.message.editing {
    opacity: 1;
}

.message-edit-textarea {
    width: 100%;
    background: var(--message-user-bg);
    border: 2px solid rgba(110, 142, 251, 0.3);
    border-radius: var(--border-radius);
    padding: 20px 24px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    line-height: 1.6;
    resize: none;
    outline: none;
    min-height: 60px;
    transition: border-color 0.2s ease;
    /* Hide scrollbar but keep scrolling functionality */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.message-edit-textarea::-webkit-scrollbar {
    display: none;
}

.message-edit-textarea:focus {
    border-color: #6e8efb;
    box-shadow: 0 0 0 3px rgba(110, 142, 251, 0.1);
}

.message-edit-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

.message-edit-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

.message-edit-btn.save {
    background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
    color: white;
}

.message-edit-btn.save:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(110, 142, 251, 0.4);
}

.message-edit-btn.cancel {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.message-edit-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

.message-edit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.message-edit-btn i.fa-spinner {
    animation: spin 1s linear infinite;
}

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

.input-container {
    padding: 24px;
}

.input-box {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.message-input {
    width: 100%;
    padding: 16px 56px 16px 20px;
    background: var(--input-bg);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 16px;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    outline: none;
    border: none;
    font-family: inherit;
    transition: background 0.2s;
    /* Allow text input and selection */
    -webkit-user-select: text;
    user-select: text;
    /* Hide scrollbar but keep scrolling functionality */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.message-input::-webkit-scrollbar {
    display: none;
}

.message-input:focus {
    background: #1a1a1a;
}

.message-input::placeholder {
    color: var(--text-secondary);
}

.send-button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.send-button:hover {
    background: #e0e0e0;
    transform: translateY(-50%) scale(1.05);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: translateY(-50%);
}

/* Text streaming animations */
.streaming-text {
    opacity: 0;
    animation: fadeInChar 0.1s ease-in forwards;
}

.streaming-message {
    position: relative;
}

.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--text-primary);
    animation: blinkCursor 1s infinite;
    margin-left: 2px;
    vertical-align: text-bottom;
}

.typing-indicator {
    opacity: 0.6;
    font-style: italic;
    color: var(--text-secondary);
    animation: pulse 1.5s ease-in-out infinite;
}

.ai-thinking {
    opacity: 0.7;
    background: var(--message-ai-bg);
    border-radius: var(--border-radius);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: thinkingBounce 1.4s ease-in-out infinite;
}

.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }
.thinking-dot:nth-child(3) { animation-delay: 0s; }

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

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

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

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

@keyframes thinkingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mobile backdrop overlay */
.mobile-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 5;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.mobile-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive Design */
@media (max-width: 767px) {
    body {
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }
    
    .settings-menu {
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 100 !important;
    }
    
    .settings-backdrop {
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        z-index: 50 !important;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        z-index: 15;
        transform: translateX(-100%);
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
        padding-top: env(safe-area-inset-top);
    }
    
    .sidebar-close {
        display: none;
        position: absolute;
        top: calc(20px + env(safe-area-inset-top));
        right: 20px;
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        border-radius: 12px;
        color: var(--text-primary);
        cursor: pointer;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        font-size: 18px;
    }
    
    .sidebar-close:active {
        transform: scale(0.9);
        background: rgba(255, 255, 255, 0.1);
    }
    
    .sidebar.open .sidebar-close {
        display: flex;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .menu-toggle {
        display: flex;
        position: fixed;
        top: calc(20px + env(safe-area-inset-top));
        left: calc(20px + env(safe-area-inset-left));
        z-index: 25;
        background: transparent;
        width: 48px;
        height: 48px;
        border-radius: 16px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border: none;
        transition: all 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        color: var(--text-primary);
    }
    
    .menu-toggle.hidden {
        opacity: 0;
        pointer-events: none;
        transform: scale(0.8);
    }
    
    .menu-toggle:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.1);
    }
    
    .version-switcher-container {
        left: 50%;
    }
    
    body {
        overflow: hidden; /* Prevent any body scrolling on mobile */
        height: 100dvh;
        max-height: 100dvh;
    }
    
    .chat-container {
        padding-top: 80px;
        height: 100dvh;
        max-height: 100dvh;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .chat-messages {
        padding: 16px;
        gap: 16px;
    }
    
    .message-content {
        padding: 16px 20px;
        font-size: 15px;
    }
    
    .input-container {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    
    .message-input {
        font-size: 16px;
        padding: 14px 52px 14px 18px;
        min-height: 20px;
    }
    
    .message-input:focus {
        background: #1a1a1a;
    }
    
    /* Optimize for mobile keyboard */
    .input-container {
        position: relative;
    }
    
    /* Better mobile scrolling */
    .chat-messages {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Disable text selection in message content for app-like experience */
    .message-content {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    
    /* Better mobile font rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
    
    .send-button {
        width: 44px;
        height: 44px;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        -webkit-tap-highlight-color: transparent;
    }
    
    .send-button:active {
        transform: translateY(-50%) scale(0.9);
    }
    
    .send-button:disabled {
        transform: translateY(-50%);
    }
    
    .new-chat-btn {
        margin: 16px;
        padding: 16px;
        font-size: 15px;
        -webkit-tap-highlight-color: transparent;
    }
    
    .new-chat-btn:active {
        transform: scale(0.98);
    }
    
    .history-item {
        padding: 16px;
        margin: 0 16px 12px;
        font-size: 15px;
        -webkit-tap-highlight-color: transparent;
    }
    
    .history-item:active {
        transform: scale(0.98);
    }
    
    /* Mobile styles for empty chat */
    .empty-chat {
        padding: 4px 12px;
        height: calc(100% - 80px); /* Take remaining space after input area */
        max-height: calc(100% - 80px);
        justify-content: flex-start;
        padding-top: 20px;
        padding-bottom: 20px;
        overflow-y: auto;
        overflow-x: hidden;
        box-sizing: border-box;
        flex-shrink: 1;
        -webkit-overflow-scrolling: touch;
    }
    
    .welcome-section {
        margin-bottom: 16px;
        flex-shrink: 0;
    }
    
    .welcome-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
        margin-bottom: 12px;
        box-shadow: 0 4px 20px rgba(110, 142, 251, 0.2);
    }
    
    .welcome-title {
        font-size: 20px;
        margin-bottom: 6px;
        letter-spacing: -0.5px;
        line-height: 1.1;
    }
    
    .welcome-subtitle {
        font-size: 12px;
        line-height: 1.2;
        max-width: 280px;
        margin: 0 auto;
    }
    
    .suggestions-title {
        font-size: 14px;
        margin-bottom: 12px;
        font-weight: 600;
    }
    
    .suggestions-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        max-width: 100%;
        flex: 1;
        align-items: start;
    }
    
    .suggestion-card {
        padding: 10px;
        border-radius: 8px;
        -webkit-tap-highlight-color: transparent;
        min-height: 60px;
        height: auto;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    
    .suggestion-card:active {
        transform: scale(0.97);
        transition: transform 0.1s ease;
    }
    
    .suggestion-icon {
        width: 28px;
        height: 28px;
        font-size: 12px;
        margin-bottom: 6px;
        border-radius: 6px;
        flex-shrink: 0;
    }
    
    .suggestion-text {
        font-size: 12px;
        margin-bottom: 3px;
        font-weight: 600;
        line-height: 1.1;
    }
    
    .suggestion-desc {
        font-size: 10px;
        line-height: 1.1;
        opacity: 0.8;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
}

/* Extra small devices (older/smaller phones) */
@media (max-width: 480px) {
    .empty-chat {
        padding: 2px 8px;
        height: calc(100% - 70px); /* Take remaining space after input area */
        max-height: calc(100% - 70px);
        padding-top: 16px;
        padding-bottom: 16px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    .welcome-section {
        margin-bottom: 12px;
    }
    
    .welcome-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .welcome-title {
        font-size: 20px;
        margin-bottom: 6px;
    }
    
    .welcome-subtitle {
        font-size: 12px;
        max-width: 260px;
    }
    
    .suggestions-title {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    .suggestions-grid {
        gap: 6px;
    }
    
    .suggestion-card {
        padding: 10px;
        min-height: 60px;
        border-radius: 8px;
    }
    
    .suggestion-icon {
        width: 28px;
        height: 28px;
        font-size: 12px;
        margin-bottom: 6px;
        border-radius: 6px;
    }
    
    .suggestion-text {
        font-size: 12px;
        margin-bottom: 3px;
    }
    
    .suggestion-desc {
        font-size: 10px;
        line-height: 1.1;
    }
    
    /* Optimize input area for very small screens */
    .input-container {
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    
    .message-input {
        padding: 12px 48px 12px 16px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .send-button {
        width: 44px;
        height: 44px;
        right: 8px;
    }
}

/* Tablet-specific fixes */
@media (min-width: 768px) and (max-width: 1024px) {
    .suggestions-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 12px;
        padding: 0 12px;
    }
    
    .empty-chat {
        max-width: 100%;
        padding: 20px 12px;
    }
    
    .welcome-section {
        margin-bottom: 30px;
    }
}

@media (min-width: 768px) {
    .menu-toggle {
        display: none !important;
    }
    
    .sidebar-close {
        display: none !important;
    }
    
    .new-chat-header-btn {
        right: calc(24px + env(safe-area-inset-right));
    }
}

/* Fluid Gradient Animations */
@keyframes fluidGradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes fluidGradientSlow {
    0% {
        background-position: 0% 50%;
    }
    33% {
        background-position: 100% 0%;
    }
    66% {
        background-position: 0% 100%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Accessibility: Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    .toggle-switch.active,
    .user-avatar,
    .welcome-icon {
        animation: none;
        background: linear-gradient(135deg, #6e8efb, #a777e3);
        background-size: 100% 100%;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Loading Screen - Enhanced Minimalistic */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
}

.loading-screen::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 700px;
    height: 700px;
    background: radial-gradient(circle at center, 
        rgba(110, 142, 251, 0.12) 0%, 
        rgba(167, 119, 227, 0.08) 30%,
        rgba(110, 142, 251, 0.04) 50%, 
        transparent 70%);
    animation: pulseGlow 5s ease-in-out infinite;
    border-radius: 50%;
    filter: blur(60px);
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.loading-logo {
    font-size: 64px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    letter-spacing: -2.5px;
    opacity: 0;
    animation: logoFadeSlide 1s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards;
    text-shadow: 0 0 40px rgba(110, 142, 251, 0.15);
}

.logo-dot {
    display: inline-block;
    color: #6e8efb;
    animation: dotPulse 2s ease-in-out infinite;
    text-shadow: 0 0 20px rgba(110, 142, 251, 0.6);
}

.loading-status {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 48px;
    opacity: 0;
    font-weight: 400;
    letter-spacing: 0.8px;
    animation: statusFadeIn 0.8s ease-out 0.6s forwards;
}

.loading-bar {
    width: 280px;
    height: 3px;
    margin: 0 auto;
    background: rgba(110, 142, 251, 0.1);
    border-radius: 10px;
    overflow: hidden;
    opacity: 0;
    position: relative;
    animation: barFadeIn 0.8s ease-out 0.8s forwards;
    box-shadow: 0 2px 10px rgba(110, 142, 251, 0.05);
}

.loading-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(110, 142, 251, 0.1) 50%, 
        transparent 100%);
    animation: shimmer 2s ease-in-out infinite;
}

.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, 
        #6e8efb 0%, 
        #8b7ae8 20%,
        #a777e3 40%,
        #c777c7 60%,
        #a777e3 80%,
        #6e8efb 100%);
    background-size: 300% 100%;
    border-radius: 10px;
    animation: barProgress 2.5s cubic-bezier(0.4, 0, 0.2, 1) infinite, 
               gradientShift 4s ease-in-out infinite;
    box-shadow: 0 0 25px rgba(110, 142, 251, 0.5), 
                0 0 50px rgba(110, 142, 251, 0.25),
                0 0 10px rgba(167, 119, 227, 0.3);
}

/* Enhanced Keyframe Animations */
@keyframes pulseGlow {
    0%, 100% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(0.95);
    }
    50% {
        opacity: 0.7;
        transform: translate(-50%, -50%) scale(1.15);
    }
}

@keyframes logoFadeSlide {
    0% {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    60% {
        opacity: 1;
        transform: translateY(5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes dotPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        color: #6e8efb;
    }
    25% {
        opacity: 0.6;
        transform: scale(1.4);
        color: #8b7ae8;
    }
    50% {
        opacity: 0.4;
        transform: scale(1.2);
        color: #a777e3;
    }
    75% {
        opacity: 0.7;
        transform: scale(1.3);
        color: #8b7ae8;
    }
}

@keyframes statusFadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 0.8;
        transform: translateY(0);
    }
}

@keyframes barFadeIn {
    0% {
        opacity: 0;
        transform: scaleX(0.5);
    }
    60% {
        opacity: 1;
        transform: scaleX(1.05);
    }
    100% {
        opacity: 1;
        transform: scaleX(1);
    }
}

@keyframes barProgress {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(220%);
    }
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(200%);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

@keyframes fadeInContent {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutContent {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Chat Context Menu */
.chat-context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    min-width: 200px;
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-context-menu.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.context-menu-header {
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
}

.context-menu-actions {
    display: flex;
    gap: 8px;
    padding: 8px;
}

.context-menu-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.context-menu-btn.delete {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.context-menu-btn.delete:hover {
    background: rgba(239, 68, 68, 0.25);
}

.context-menu-btn.delete:active {
    transform: scale(0.95);
}

.context-menu-btn.cancel {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.context-menu-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.12);
}

.context-menu-btn.cancel:active {
    transform: scale(0.95);
}

/* Context menu backdrop */
.context-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 9998;
    display: none;
}

.context-menu-backdrop.show {
    display: block;
}

/* Message Context Menu */
.message-context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    min-width: 160px;
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.message-context-menu.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.message-context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.message-context-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.message-context-menu-item:active {
    transform: scale(0.98);
}

.message-context-menu-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.message-context-menu-item.delete {
    color: #ef4444;
}

.message-context-menu-item.delete:hover {
    background: rgba(239, 68, 68, 0.15);
}

.message-context-menu-item.edit i {
    color: #3b82f6;
}

.message-context-menu-item.copy i {
    color: #10b981;
}

.message-context-menu-item.regenerate i {
    color: #8b5cf6;
}

.message-context-menu-item.delete i {
    color: #ef4444;
}

/* Make messages interactive - merged with main .message styles */

/* Edit message input */
.message-edit-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-edit-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}

.message-edit-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.message-edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.message-edit-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-edit-btn.save {
    background: var(--primary-color);
    color: white;
}

.message-edit-btn.save:hover {
    opacity: 0.9;
}

.message-edit-btn.cancel {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.message-edit-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.12);
}