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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    background: #f5f7fa;
    height: 100vh;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

header {
    padding: 16px 24px;
    border-bottom: 1px solid #e8ecf0;
    background: #fff;
    flex-shrink: 0;
}

header h1 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a2e;
    text-align: center;
}

.question-card {
    margin: 16px 24px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: #fff;
    flex-shrink: 0;
}

.question-card.hidden {
    display: none;
}

.question-topic {
    display: inline-block;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 10px;
    border-radius: 10px;
    margin-bottom: 8px;
}

.question-text {
    font-size: 16px;
    line-height: 1.6;
    font-weight: 500;
}

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 15px;
}

.message {
    max-width: 80%;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}

.message.user {
    align-self: flex-end;
    background: #3b82f6;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: #f0f2f5;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
}

.message.loading {
    align-self: flex-start;
    background: #f0f2f5;
    color: #888;
    font-style: italic;
}

.message.error {
    align-self: center;
    background: #fef2f2;
    color: #dc2626;
    font-size: 13px;
    border-radius: 8px;
}

.message.reference-answer {
    align-self: stretch;
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.8;
    margin-top: 8px;
}

.input-area {
    padding: 12px 24px 20px;
    border-top: 1px solid #e8ecf0;
    background: #fff;
    flex-shrink: 0;
}

.next-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 2px dashed #667eea;
    background: transparent;
    color: #667eea;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.next-btn:hover {
    background: #667eea;
    color: #fff;
}

.input-row {
    display: flex;
    gap: 8px;
}

.input-row textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e4e8;
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
}

.input-row textarea:focus {
    border-color: #3b82f6;
}

.input-row textarea:disabled {
    background: #f9fafb;
    cursor: not-allowed;
}

.input-row button {
    padding: 12px 24px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.input-row button:hover:not(:disabled) {
    background: #2563eb;
}

.input-row button:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .container {
        box-shadow: none;
    }

    header {
        padding: 12px 16px;
    }

    .question-card {
        margin: 12px 16px;
    }

    .chat-area {
        padding: 12px 16px;
    }

    .input-area {
        padding: 10px 16px 16px;
    }

    .message {
        max-width: 88%;
    }
}
