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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 900px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-height: 800px;
}

header {
    background: white;
    color: #1c1e21;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e4e6eb;
}

header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #1877f2;
}

.model-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.model-badge {
    background: #e7f3ff;
    color: #1877f2;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
}

.device-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #b0b3b8;
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #1877f2;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

input:disabled + .slider {
    opacity: 0.5;
    cursor: not-allowed;
}

#deviceLabel {
    font-size: 12px;
    font-weight: 600;
    color: #65676b;
}

.chat-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.chat-messages {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #65676b;
}

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

.welcome-message h2 {
    color: #1c1e21;
    margin-bottom: 10px;
    font-weight: 700;
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

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

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

.message-content {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
    font-size: 15px;
}

.message.user .message-content {
    background: #1877f2;
    color: white;
}

.message.assistant .message-content {
    background: #e4e6eb;
    color: #1c1e21;
}

.message.error .message-content {
    background: #fee;
    color: #c00;
}

.loading-indicator {
    padding: 0 20px 20px;
}

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

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #e4e6eb;
    border-radius: 18px;
    width: fit-content;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #65676b;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

.input-container {
    padding: 16px 20px;
    border-top: 1px solid #e4e6eb;
    background: white;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ccd0d5;
    border-radius: 20px;
    font-size: 15px;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    max-height: 120px;
    line-height: 1.4;
    background: #f0f2f5;
}

#userInput:focus {
    border-color: #1877f2;
    background: white;
}

.send-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #1877f2;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
}

.send-button:hover:not(:disabled) {
    background: #166fe5;
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 0 4px;
}

#charCount {
    font-size: 12px;
    color: #65676b;
}

.clear-button {
    font-size: 12px;
    color: #1877f2;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
    font-weight: 600;
}

.clear-button:hover {
    background: #e7f3ff;
}

.init-loader {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    display: none;
}

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

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #e4e6eb;
    border-top: 3px solid #1877f2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loader-content p {
    color: #1c1e21;
    margin-bottom: 8px;
    font-weight: 600;
}

.loader-subtext {
    font-size: 13px;
    color: #65676b;
    font-weight: 400;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.1);
    transform: translateX(400px);
    transition: transform 0.3s;
    z-index: 2000;
    font-size: 14px;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-left: 4px solid #42b883;
}

.notification.error {
    border-left: 4px solid #f02849;
}

.notification.info {
    border-left: 4px solid #1877f2;
}

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

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }
    
    body {
        padding: 0;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    .model-badge {
        display: none;
    }
}