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

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-sidebar: #0f3460;
    --bg-message-user: #2d6a4f;
    --bg-message-ai: #1f4068;
    --text-primary: #eaeaea;
    --text-secondary: #8892b0;
    --accent: #64ffda;
    --accent-hover: #4cd8b5;
    --border: #233554;
    --danger: #ef4444;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

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

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

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo svg {
    width: 28px;
    height: 28px;
    color: var(--accent);
}

.logo h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-list {
    flex: 1;
    padding: 15px 10px;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-secondary);
}

.chat-item:hover {
    background: rgba(100, 255, 218, 0.1);
}

.chat-item.active {
    background: rgba(100, 255, 218, 0.15);
    color: var(--text-primary);
}

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

.model-info {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
}

.model-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(100, 255, 218, 0.1);
    border: 1px solid rgba(100, 255, 218, 0.3);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    width: fit-content;
}

.model-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s infinite;
}

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

.model-info p {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 0;
}

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

.header-title h2 {
    font-size: 16px;
    font-weight: 600;
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--accent);
    margin-top: 4px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

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

.clear-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.welcome {
    text-align: center;
    margin-top: 15vh;
    padding: 0 20px;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.welcome p {
    color: var(--text-secondary);
    font-size: 15px;
    max-width: 500px;
    margin: 0 auto 30px;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

.suggestion-chip {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.suggestion-chip:hover {
    background: rgba(100, 255, 218, 0.1);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
}

/* Message bubbles */
.message {
    display: flex;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
}

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

.message.user {
    justify-content: flex-end;
}

.message.ai {
    justify-content: flex-start;
}

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

.message.user .message-avatar {
    background: var(--bg-message-user);
    margin-left: 10px;
    order: 2;
}

.message.ai .message-avatar {
    background: var(--bg-message-ai);
    margin-right: 10px;
}

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

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

.message.ai .message-content {
    align-items: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.message-meta code {
    background: rgba(100, 255, 218, 0.08) !important;
    color: var(--accent) !important;
    padding: 1px 4px !important;
    border-radius: 3px !important;
    font-size: 10px !important;
}

.message.user .message-bubble {
    background: var(--bg-message-user);
    border-bottom-right-radius: 4px;
}

.message.ai .message-bubble {
    background: var(--bg-message-ai);
    border-bottom-left-radius: 4px;
}

.message-bubble.code {
    font-family: 'Courier New', monospace;
    background: #0d1b2a;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px;
    overflow-x: auto;
}

/* Markdown styles */
.message-bubble p {
    margin-bottom: 8px;
}

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

.message-bubble pre {
    background: #0d1b2a;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.5;
}

.message-bubble code {
    background: rgba(100, 255, 218, 0.1);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.message-bubble pre code {
    background: transparent;
    color: var(--text-primary);
    padding: 0;
}

.message-bubble ul, .message-bubble ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-bubble li {
    margin-bottom: 4px;
}

.message-bubble h1, .message-bubble h2, .message-bubble h3 {
    margin: 12px 0 8px;
    font-weight: 600;
}

.message-bubble blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-bubble table {
    border-collapse: collapse;
    margin: 8px 0;
    width: 100%;
}

.message-bubble th, .message-bubble td {
    border: 1px solid var(--border);
    padding: 6px 12px;
    text-align: left;
}

.message-bubble th {
    background: var(--bg-secondary);
}

/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: bounce 1.4s infinite;
}

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

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

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* Input area */
.input-area {
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
}

#chatForm {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 16px;
    transition: border-color 0.2s;
}

#chatForm:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(100, 255, 218, 0.1);
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 150px;
    line-height: 1.5;
    padding: 4px 0;
}

#userInput::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    background: var(--accent);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn svg {
    width: 18px;
    height: 18px;
    color: var(--bg-primary);
}

.send-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: scale(1);
}

.disclaimer {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 12px;
}

/* Error message */
.message.error .message-bubble {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .message-content {
        max-width: 85%;
    }

    .welcome {
        margin-top: 10vh;
    }
}

/* Redirection banner styles */
.redirect-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(100, 255, 218, 0.08);
    border: 1px solid rgba(100, 255, 218, 0.25);
    border-radius: 10px;
    padding: 10px 14px;
    margin-top: 12px;
    font-size: 13px;
    animation: fadeIn 0.4s ease;
}

.redirect-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.redirect-icon {
    font-size: 16px;
    animation: pulse 1s infinite alternate;
}

.redirect-text {
    color: var(--text-primary);
    font-weight: 500;
}

.redirect-button {
    background: var(--accent);
    color: var(--bg-primary);
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.2s ease;
}

.redirect-button:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}