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

:root {
    --sidebar-width: 280px;
    --primary: #ff3131;
    --primary-hover: #e02828;
    --primary-light: rgba(255, 49, 49, 0.1);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

body {
    font-family: 'Geist', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 400;
}

body.dark {
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --bg-primary: #0f172a;
    --bg-secondary: #020617;
    --bg-tertiary: #1e293b;
    --border: #334155;
    --border-light: #1e293b;
    --primary-light: rgba(255, 49, 49, 0.2);
}

/* New Animations */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

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

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 16px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
}

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

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

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

/* Model indicator pulse */
.model-indicator.ready {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* System Message */
.system-message {
    text-align: center;
    padding: 12px;
    margin: 16px 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-style: italic;
    border: 1px solid var(--border);
    animation: fadeIn 0.3s ease-out;
}

/* No chats message */
.no-chats {
    color: var(--text-tertiary);
    padding: 16px;
    text-align: center;
    font-size: 13px;
}

/* Trial Status */
.trial-status {
    position: fixed;
    top: 16px;
    right: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
    z-index: 100;
    backdrop-filter: blur(10px);
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    background: var(--bg-primary);
}

/* Auth Container */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-secondary);
    padding: 24px;
}

.auth-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: white;
    margin: 0 auto 16px;
}

.auth-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-align: center;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
    font-weight: 400;
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    transition: all 0.2s;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 400;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.phone-input-group {
    display: flex;
    gap: 12px;
}

.country-code {
    width: 90px;
}

.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.verification-code {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 32px 0;
}

.code-input {
    width: 54px;
    height: 54px;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.code-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
}

.sidebar-logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

/* Enhanced New Chat Button */
.new-chat-btn {
    width: 100%;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--primary), #ff5555);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.new-chat-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover), #ff4444);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.new-chat-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.new-chat-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.new-chat-btn:hover::before {
    left: 100%;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.chat-list-section {
    margin-bottom: 24px;
}

.chat-list-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    padding: 0 8px;
    letter-spacing: 0.05em;
}

/* Enhanced Chat Items */
.chat-item {
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.chat-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(2px);
}

.chat-item.active {
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    font-weight: 600;
}

.chat-item-icon {
    font-size: 16px;
    opacity: 0.8;
}

.chat-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    border: 1px solid var(--border);
}

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

.user-tier {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tier-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-transform: uppercase;
}

.tier-badge.free {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.tier-badge.pro {
    background: linear-gradient(135deg, #ff3131, #ff6b6b);
    color: white;
}

.settings-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 16px;
}

.settings-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: rotate(90deg);
}

/* Main Chat Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    height: 72px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--bg-primary);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-outline {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.btn-outline:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.btn-small {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.btn-small:hover {
    background: var(--primary-hover);
}

.back-to-home {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.back-to-home:hover {
    color: var(--text-primary);
}

.chat-header-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* Enhanced Model/Mode Selectors */
.model-selector-btn,
.mode-selector-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 600;
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.model-selector-btn:hover,
.mode-selector-btn:hover {
    background: var(--bg-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.model-selector-btn:active,
.mode-selector-btn:active {
    transform: translateY(0);
}

.model-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.model-indicator.ready {
    background: #10b981;
}

.mode-icon {
    font-size: 16px;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
}

.messages-wrapper {
    max-width: 768px;
    margin: 0 auto;
    padding: 48px 32px 140px;
}

.welcome-screen {
    text-align: center;
    padding: 80px 0;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.8;
}

.welcome-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.welcome-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    font-weight: 400;
}

.welcome-suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.suggestion-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.suggestion-card:hover {
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

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

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

.suggestion-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.message-group {
    margin-bottom: 32px;
    animation: messageSlide 0.3s ease-out;
}

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

.message {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    max-width: 80%;
}

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

.message.assistant {
    margin-right: auto;
    flex-direction: row;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.message.user .message-avatar {
    background: var(--primary);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.message-content {
    flex: 1;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    font-weight: 400;
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    position: relative;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.message.user .message-content {
    background: var(--primary);
    color: white;
    font-weight: 500;
    border: none;
    margin-left: 8px;
}

.message.assistant .message-content {
    background: var(--bg-primary);
    color: var(--text-primary);
    margin-right: 8px;
}

/* Message Bubbles */
.message.user .message-content::before {
    content: '';
    position: absolute;
    top: 12px;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: var(--primary);
}

.message.assistant .message-content::before {
    content: '';
    position: absolute;
    top: 12px;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-right-color: var(--bg-primary);
}

/* Enhanced Message Files */
.message-files {
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.message-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    font-size: 13px;
}

.message.assistant .message-file {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.message-file-preview {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.message-file-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 16px;
}

.message-file-name {
    font-weight: 500;
    color: inherit;
}

/* Input Area */
.input-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, var(--bg-primary) 70%, transparent);
    padding: 32px;
}

.input-wrapper {
    max-width: 768px;
    margin: 0 auto;
    position: relative;
}

.input-box {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: all 0.2s;
    position: relative;
}

.input-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light), var(--shadow-lg);
    transform: translateY(-2px);
}

.message-input {
    width: 100%;
    border: none;
    padding: 20px 64px 20px 20px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 200px;
    background: transparent;
    color: var(--text-primary);
    font-weight: 400;
    line-height: 1.5;
}

.message-input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.input-actions {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px) scale(1.05);
    box-shadow: var(--shadow-md);
}

.send-btn:active:not(:disabled) {
    transform: translateY(0) scale(1);
}

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

.attach-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 16px;
}

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

.attach-btn.has-files {
    background: var(--primary-light);
    color: var(--primary);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Beta Notice */
.beta-notice {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.beta-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.beta-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.beta-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

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

.btn-secondary {
    padding: 12px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Model Selection Modal */
.model-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 90%;
    max-width: 650px;
    box-shadow: var(--shadow-lg);
}

.model-modal-header {
    text-align: center;
    margin-bottom: 32px;
}

.model-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.model-modal-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
}

.model-options {
    display: grid;
    gap: 16px;
    margin-bottom: 32px;
}

.model-option {
    padding: 24px;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-primary);
}

.model-option:hover:not(.disabled) {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.model-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.model-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.model-icon {
    font-size: 36px;
    width: 60px;
    text-align: center;
}

.model-info {
    flex: 1;
}

.model-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

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

.model-badge {
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.model-badge.ready {
    background: #dcfce7;
    color: #166534;
}

.model-badge.pro {
    background: #fef3c7;
    color: #92400e;
}

.model-badge.coming-soon {
    background: var(--border);
    color: var(--text-tertiary);
}

body.dark .model-badge.ready {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

body.dark .model-badge.pro {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

/* Settings */
.settings-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    max-height: 85vh;
    overflow-y: auto;
}

.settings-header {
    text-align: center;
    margin-bottom: 32px;
}

.settings-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

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

.settings-section {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

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

.settings-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.settings-item:last-child {
    margin-bottom: 0;
}

.settings-item-left {
    flex: 1;
}

.settings-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

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

/* Account Status */
.account-status {
    padding: 4px 12px;
    background: #dcfce7;
    color: #166534;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
}

body.dark .account-status {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

/* Plan Badge */
.plan-badge {
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-badge.free {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.plan-badge.pro {
    background: linear-gradient(135deg, #ff3131, #ff6b6b);
    color: white;
}

/* Usage Bar */
.usage-bar {
    width: 120px;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.usage-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.usage-fill.warning {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.usage-fill.danger {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

/* Theme Selector */
.theme-selector {
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.theme-option:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.theme-option.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.theme-icon {
    font-size: 14px;
}

/* Settings Footer */
.settings-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.settings-version {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Enhanced Toggle Switch */
.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    background: var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-switch.active {
    background: var(--primary);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.toggle-switch.active::after {
    transform: translateX(24px);
}

/* File Upload */
.file-upload-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
}

.file-upload-modal-header {
    text-align: center;
    margin-bottom: 32px;
}

.file-upload-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.file-upload-modal-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
}

.file-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    margin: 20px 0;
    transition: all 0.2s;
    cursor: pointer;
    background: var(--bg-secondary);
}

.file-upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

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

.file-upload-hint {
    font-size: 14px;
    color: var(--text-secondary);
}

.uploaded-files {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 16px 0;
}

.uploaded-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-primary);
}

.uploaded-file-preview {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-tertiary);
}

.uploaded-file-info {
    flex: 1;
}

.uploaded-file-name {
    font-weight: 500;
    margin-bottom: 2px;
}

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

.remove-file-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: var(--text-tertiary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.2s;
}

.remove-file-btn:hover {
    background: #ef4444;
}

/* Loading */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-16 {
    margin-top: 16px;
}

.text-error {
    color: #ef4444;
    font-size: 13px;
    margin-top: 8px;
}

/* Scrollbar Styling */
.chat-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar,
.settings-modal::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track,
.settings-modal::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.chat-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb,
.settings-modal::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
    transition: background 0.2s;
}

.chat-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover,
.settings-modal::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Firefox Scrollbar */
.chat-list,
.messages-container,
.settings-modal {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-secondary);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .messages-wrapper {
        padding: 24px 20px 140px;
    }

    .input-container {
        padding: 20px;
    }

    .welcome-title {
        font-size: 28px;
    }

    .welcome-suggestions {
        grid-template-columns: 1fr;
    }

    .model-modal,
    .settings-modal,
    .beta-notice,
    .file-upload-modal {
        width: 95%;
        padding: 24px;
    }

    /* Mobile message layout */
    .message {
        max-width: 90%;
    }

    .message-content {
        padding: 12px 16px;
        font-size: 14px;
    }

    /* Mobile user info */
    .user-info {
        padding: 12px;
    }

    .user-phone {
        font-size: 13px;
    }

    .user-tier {
        font-size: 11px;
    }

    .tier-badge {
        font-size: 9px;
        padding: 1px 4px;
    }

    /* Mobile chat list */
    .chat-item {
        padding: 12px 14px;
    }

    .chat-item-title {
        font-size: 13px;
    }

    .chat-list-title {
        font-size: 10px;
        padding: 6px 10px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .sidebar-logo-icon,
    .message-avatar,
    .settings-btn {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Focus and Accessibility */
.new-chat-btn:focus,
.chat-item:focus,
.settings-btn:focus,
.send-btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
