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

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #171717;
    --bg-tertiary: #1e1e1e;
    --bg-hover: #262626;
    --border: #2a2a2a;
    --border-light: #333;
    --text-primary: #e5e5e5;
    --text-secondary: #a0a0a0;
    --text-muted: #666;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --user-bg: #6366f1;
    --user-text: #fff;
    --assistant-bg: #1e1e1e;
    --assistant-text: #e5e5e5;
    --radius: 16px;
    --radius-sm: 10px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app {
    display: flex;
    height: 100%;
    overflow: hidden;
}

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

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

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

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    color: #fff;
}

.logo-text {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.sidebar-info {
    padding: 20px;
    flex: 1;
}

.info-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.info-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.info-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    transition: background var(--transition), color var(--transition);
}

.info-links a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-footer p {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    height: 56px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.mobile-menu {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

/* Chat area */
.chat {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Welcome screen */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    padding: 40px 20px;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-icon {
    width: 56px;
    height: 56px;
    background: var(--accent-glow);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-hover);
    margin-bottom: 20px;
}

.welcome h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.welcome > p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.6;
}

.suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}

.suggestion {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-family: var(--font);
    cursor: pointer;
    text-align: left;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    line-height: 1.4;
}

.suggestion:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

/* Messages */
.message {
    display: flex;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    animation: fadeIn 0.3s ease-out;
}

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

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

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

.message-content {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    line-height: 1.7;
}

.message.user .message-content {
    background: var(--user-bg);
    color: var(--user-text);
    border-bottom-right-radius: 6px;
}

.message.assistant .message-content {
    background: var(--assistant-bg);
    color: var(--assistant-text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
}

.message-content p + p { margin-top: 10px; }
.message-content strong { font-weight: 600; color: #f5f5f5; }

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

.message-content li { margin: 4px 0; }

.message-content code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8125em;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.message-content a {
    color: var(--accent-hover);
    text-decoration: none;
}

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

.message-content h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 12px 0 4px;
    color: #f5f5f5;
}

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

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: pulse 1.4s infinite ease-in-out;
}

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

@keyframes pulse {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

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

.input-area {
    display: flex;
    gap: 10px;
    max-width: 720px;
    margin: 0 auto;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 4px 4px 4px 16px;
    transition: border-color var(--transition);
}

.input-area:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#input {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--text-primary);
    outline: none;
}

#input::placeholder {
    color: var(--text-muted);
}

#send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform var(--transition);
    flex-shrink: 0;
}

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

#send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.disclaimer {
    text-align: center;
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Error */
.error-msg {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: var(--radius-sm);
}

/* Scrollbar */
.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.chat::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10;
}

.sidebar-overlay.active { display: block; }

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 20;
        width: 280px;
        transition: left var(--transition);
    }

    .sidebar.open { left: 0; }

    .mobile-menu { display: block; }

    .chat { padding: 16px; }

    .input-wrapper { padding: 12px 16px 16px; }

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

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

    .welcome {
        padding: 24px 12px;
    }
}

@media (max-width: 400px) {
    .chat-header { padding: 0 16px; }

    .message-content {
        padding: 10px 14px;
        font-size: 0.8125rem;
    }
}
