* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

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

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    text-align: left;
}

header h1 {
    font-size: 24px;
    margin-bottom: 2px;
    font-weight: 600;
}

.subtitle {
    font-size: 13px;
    opacity: 0.9;
}

.secondary-button {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.secondary-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.settings-container {
    display: none;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.role-selection {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #666;
}

#roleSelect {
    padding: 5px 10px;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    outline: none;
    color: #333;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.chat-window::-webkit-scrollbar {
    width: 8px;
}

.chat-window::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-window::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-window::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.welcome-message {
    margin-bottom: 20px;
}

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

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

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

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

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message-content p {
    margin-bottom: 8px;
}

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

.disclaimer {
    font-size: 12px;
    opacity: 0.8;
    font-style: italic;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-message .disclaimer {
    border-top-color: #e0e0e0;
    color: #666;
}

.loading-container {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
    font-size: 14px;
}

.loading {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

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

.input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

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

.upload-button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.upload-button:hover {
    opacity: 1;
}

#userInput {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    font-size: 15px;
    transition: border-color 0.2s;
}

.image-preview-container {
    padding: 10px;
    background: #f9f9f9;
    border-radius: 10px;
    margin-bottom: 10px;
}

.preview-wrapper {
    position: relative;
    display: inline-block;
}

#imagePreview {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4d4d;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 14px;
    line-height: 20px;
}

.message-image {
    max-width: 300px;
    border-radius: 10px;
    margin-top: 10px;
    cursor: pointer;
}

/* Thinking Box Styles */
.thinking-box {
    background: #f0f4ff;
    border-left: 4px solid #667eea;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
    font-size: 14px;
}

.thinking-header {
    background: #e6edff;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.thinking-title {
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 12px;
}

.thinking-content {
    padding: 12px;
    color: #4a5568;
    font-style: italic;
    line-height: 1.5;
    border-top: 1px solid #e2e8f0;
}

.thinking-box.streaming .thinking-header {
    background: #fff5f5;
    border-bottom: 1px solid #fed7d7;
}

.thinking-box.streaming {
    border-left-color: #f56565;
    background: #fffaf0;
}

.thinking-box.streaming .thinking-title {
    color: #c53030;
}

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

#userInput:focus {
    border-color: #667eea;
}

#userInput:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.send-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 80px;
}

.send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-button:active:not(:disabled) {
    transform: translateY(0);
}

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

.stop-button {
    padding: 12px 18px;
    background: #ff4d4d;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 80px;
}

.stop-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.35);
}

.stop-button:active:not(:disabled) {
    transform: translateY(0);
}

.stop-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.style-toggle label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    padding: 6px 12px;
    border-radius: 15px;
    transition: background 0.2s;
}

.style-toggle label:hover {
    background: #f0f0f0;
}

.style-toggle input[type="radio"] {
    cursor: pointer;
}

.style-toggle input[type="radio"]:checked + span {
    color: #667eea;
    font-weight: 600;
}

.status-bar {
    padding: 10px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    font-size: 12px;
    color: #666;
    text-align: center;
}

.status-bar.error {
    background: #fee;
    color: #c33;
}

.status-bar.success {
    background: #efe;
    color: #3c3;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    header {
        padding: 15px 20px;
    }

    header h1 {
        font-size: 24px;
    }

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

    .input-container {
        padding: 15px;
    }

    .style-toggle {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0;
    }

    .message-content {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 14px;
    }

    #userInput {
        font-size: 14px;
        padding: 10px 14px;
    }

    .send-button {
        padding: 10px 20px;
        font-size: 14px;
    }
}
