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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', sans-serif;
    background: #f5f5f5;
    height: 100vh;
}

/* ========== 登录页面 ========== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    font-size: 32px;
    margin-bottom: 10px;
    color: #333;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

.password-form {
    margin-bottom: 20px;
}

.password-form input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 15px;
    transition: border-color 0.3s;
}

.password-form input:focus {
    outline: none;
    border-color: #667eea;
}

.password-form button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

.password-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.error {
    color: #f44336;
    font-size: 14px;
    display: none;
}

/* ========== 聊天页面 ========== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    position: relative;
}

.chat-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.chat-header .subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    margin-bottom: 0;
}

.logout-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.ai {
    align-self: flex-start;
    background: #f0f0f0;
    color: #333;
}

.message img {
    max-width: 200px;
    border-radius: 8px;
    display: block;
}

/* Typing 动画 */
.message.typing {
    padding: 8px 16px;
}

.message.typing span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

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

/* ========== 输入区域 ========== */
.input-area {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

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

.input-container input[type="text"] {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.input-container input[type="text"]:focus {
    border-color: #667eea;
}

.image-btn {
    width: 44px;
    height: 44px;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.3s;
}

.image-btn:hover {
    border-color: #667eea;
}

.send-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: translateY(-2px);
}

/* ========== 图片预览 ========== */
.preview-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 100;
}

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

.preview-box img {
    max-width: 150px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.close-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

/* ========== 响应式 ========== */
@media (max-width: 600px) {
    .message {
        max-width: 90%;
    }

    .chat-header h1 {
        font-size: 20px;
    }
}
