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

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

.container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
}

header {
    text-align: center;
    padding: 20px 0;
}

header h1 {
    color: #333;
    font-size: 1.8rem;
    margin-bottom: 5px;
}

header .subtitle {
    color: #666;
    font-size: 0.95rem;
}

.chat-container {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 20px;
    overflow-y: auto;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.welcome-message {
    color: #555;
    line-height: 1.6;
}

.welcome-message p {
    margin-bottom: 10px;
}

.welcome-message ul {
    margin-left: 20px;
    margin-top: 5px;
}

.welcome-message li {
    margin-bottom: 5px;
    color: #666;
}

.message {
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    text-align: right;
}

.message.user .bubble {
    background: #007bff;
    color: white;
    display: inline-block;
    padding: 10px 15px;
    border-radius: 18px 18px 4px 18px;
    max-width: 80%;
    text-align: left;
}

.message.assistant .bubble {
    background: #f0f0f0;
    color: #333;
    display: inline-block;
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    max-width: 90%;
    line-height: 1.5;
}

.message.assistant .bubble p {
    margin-bottom: 10px;
}

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

.message.assistant .bubble ul,
.message.assistant .bubble ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

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

.message.assistant .bubble strong {
    color: #222;
}

.message.assistant .bubble code {
    background: #e0e0e0;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}

.message.error .bubble {
    background: #ffebee;
    color: #c62828;
    display: inline-block;
    padding: 10px 15px;
    border-radius: 8px;
}

.input-container {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

#questionForm {
    display: flex;
    gap: 10px;
}

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

#questionInput:focus {
    border-color: #007bff;
}

#submitBtn {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 80px;
}

#submitBtn:hover {
    background: #0056b3;
}

#submitBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.clear-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 10px;
    padding: 5px 10px;
    transition: color 0.2s;
}

.clear-btn:hover {
    color: #333;
}

.thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #888;
    padding: 10px;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background: #888;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@media (max-width: 600px) {
    .container {
        height: calc(100vh - 20px);
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .message.user .bubble,
    .message.assistant .bubble {
        max-width: 95%;
    }
    
    #submitBtn {
        padding: 12px 18px;
    }
}

.message.assistant .bubble .katex-display {
    margin: 12px 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 0;
}

.message.assistant .bubble .katex {
    font-size: 1.1em;
}

.message.assistant .bubble .katex-display > .katex {
    font-size: 1.2em;
}

.feedback-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

.feedback-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #666;
    transition: all 0.2s;
}

.feedback-btn:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #ccc;
}

.feedback-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.feedback-btn.selected {
    border-color: #007bff;
    color: #007bff;
    background: #e7f1ff;
}

.feedback-btn.selected.negative {
    border-color: #dc3545;
    color: #dc3545;
    background: #ffebee;
}

.feedback-btn .emoji {
    font-size: 1rem;
}

.feedback-thanks {
    color: #28a745;
    font-size: 0.85rem;
    margin-left: 8px;
}

.feedback-comment {
    display: none;
    margin-top: 8px;
}

.feedback-comment.show {
    display: flex;
    gap: 8px;
}

.feedback-comment input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
}

.feedback-comment button {
    background: #007bff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.feedback-comment button:hover {
    background: #0056b3;
}

.message.limit-reached {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.limit-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
}

.limit-bubble p {
    margin-bottom: 12px;
}

.limit-bubble .demo-link {
    display: inline-block;
    background: white;
    color: #667eea;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    margin-top: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.limit-bubble .demo-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.message.admin-notice {
    display: flex;
    justify-content: center;
    margin-top: 12px;
}

.admin-bubble {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    font-size: 14px;
}

.admin-bubble p {
    margin: 0;
}
