:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --accent: #6c63ff;
    --accent-hover: #5a52e0;
    --user-bubble: #2d2d44;
    --model-bubble: #1e3a5f;
    --system-bubble: #3d3d5c;
    --border-radius: 16px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app {
    width: 100%;
    max-width: 800px;
    height: 95vh;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 16px 20px;
    background: var(--bg-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.status-dot {
    width: 10px;
    height: 10px;
    background: #ff4757;
    border-radius: 50%;
    transition: var(--transition);
}

.status-dot.connected {
    background: #2ed573;
    box-shadow: 0 0 10px #2ed573;
}

.chat-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    animation: fadeIn 0.5s ease;
}

.welcome-message h2 {
    font-size: 1.8rem;
    margin-bottom: 12px;
    color: var(--accent);
}

.welcome-message .hint {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-top: 8px;
    font-style: italic;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    line-height: 1.4;
    animation: slideIn 0.3s ease;
    position: relative;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.message.user {
    align-self: flex-end;
    background: var(--user-bubble);
    border-bottom-right-radius: 4px;
}

.message.model {
    align-self: flex-start;
    background: var(--model-bubble);
    border-bottom-left-radius: 4px;
}

.message.system {
    align-self: center;
    background: var(--system-bubble);
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 90%;
    text-align: center;
    border-radius: 12px;
}

.message .sender {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-bottom: 4px;
    display: block;
}

.typing-indicator {
    align-self: flex-start;
    background: var(--model-bubble);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    width: fit-content;
}

.typing-indicator.hidden {
    display: none;
}

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

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

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

.input-form {
    padding: 16px 20px;
    background: var(--bg-tertiary);
    display: flex;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.input-form input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 24px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

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

.input-form input:focus {
    box-shadow: 0 0 0 2px var(--accent);
}

.send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.send-btn:active {
    transform: scale(0.95);
}

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

@media (max-width: 600px) {
    .app {
        height: 100vh;
        border-radius: 0;
    }

    .message {
        max-width: 85%;
    }

    .chat-header h1 {
        font-size: 1rem;
    }
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}