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

body {
    font-family: 'Arial', 'Helvetica', sans-serif;
    background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
                url('https://media-cdn-zspms.kurogame.com/pnswebsite/website2.0/images/1765382400000/yf53h10clle4uzsizr-17654217357318.png') center / cover fixed;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chat-container {
    width: 100%;
    max-width: 700px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.5s ease-out;
    position: relative;
}

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

/* 对话框样式 */
.chat-box {
    flex: 1;
    background: transparent;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    overflow-y: auto;
    border: 2px solid rgba(100, 100, 150, 0.5);
    backdrop-filter: none;
}

.chat-box::-webkit-scrollbar {
    width: 6px;
}

.chat-box::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 消息区域 */
.messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    animation: messageSlide 0.4s ease-out;
    gap: 8px;
    align-items: center;
}

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

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

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

/* 头像样式 */
.avatar {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.ai-avatar {
    order: -1;
}

.user-avatar {
    order: 1;
}

/* 消息气泡 */
.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
}

.ai-message .message-bubble {
    background: rgba(50, 100, 200, 0.8);
    color: #ffffff;
    text-align: left;
}

.user-message .message-bubble {
    background: rgba(100, 200, 100, 0.8);
    color: #ffffff;
    text-align: right;
}

.message-bubble p {
    font-size: 16px;
    line-height: 1.4;
    margin: 0 0 6px 0;
}

.timestamp {
    font-size: 12px;
    opacity: 0.7;
    display: block;
    margin-top: 4px;
}

/* 输入框区域 */
.input-area {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: transparent;
    border-radius: 12px;
    border: 2px solid rgba(100, 100, 150, 0.5);
}

.message-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    color: #ffffff;
    padding: 10px 15px;
    font-size: 16px;
    font-family: 'Arial', 'Helvetica', sans-serif;
    resize: none;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    max-height: 100px;
}

.message-input:focus {
    border-color: rgba(100, 200, 255, 0.6);
    box-shadow: 0 0 10px rgba(100, 200, 255, 0.3);
    background: rgba(0, 0, 0, 0.7);
}

.message-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* 发送按钮 */
.send-button {
    width: 70px;
    background: linear-gradient(135deg, #00aaff 0%, #0077dd 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 170, 255, 0.3);
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 170, 255, 0.5);
    background: linear-gradient(135deg, #00ccff 0%, #0099ff 100%);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

/* 设置按钮 */
.settings-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(100, 150, 255, 0.8);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: rgba(100, 150, 255, 1);
    transform: scale(1.1);
}

/* 设置面板 */
.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.settings-panel.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.settings-content {
    background: rgba(20, 20, 40, 0.95);
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    border: 2px solid rgba(100, 150, 255, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.settings-content h3 {
    color: #00aaff;
    margin-bottom: 20px;
    font-size: 20px;
}

.settings-content label {
    display: block;
    color: #ffffff;
    margin-bottom: 8px;
    font-size: 14px;
}

.api-key-input {
    width: 100%;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(100, 150, 255, 0.5);
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.3s;
}

.api-key-input:focus {
    border-color: rgba(100, 200, 255, 0.8);
    box-shadow: 0 0 10px rgba(100, 200, 255, 0.3);
}

.settings-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.settings-save-btn,
.settings-clear-btn,
.settings-close-btn {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

.settings-save-btn {
    background: rgba(0, 200, 100, 0.8);
    color: white;
}

.settings-save-btn:hover {
    background: rgba(0, 220, 120, 1);
    transform: translateY(-2px);
}

.settings-clear-btn {
    background: rgba(200, 100, 0, 0.8);
    color: white;
}

.settings-clear-btn:hover {
    background: rgba(220, 120, 0, 1);
    transform: translateY(-2px);
}

.settings-close-btn {
    background: rgba(100, 100, 100, 0.8);
    color: white;
}

.settings-close-btn:hover {
    background: rgba(120, 120, 120, 1);
    transform: translateY(-2px);
}

.settings-hint {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    text-align: center;
    margin-top: 10px;
}

/* ===== 背景选择器样式 ===== */

/* 背景选择按钮 */
.background-btn {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: rgba(100, 150, 255, 0.8);
    border: 2px solid rgba(100, 200, 255, 0.6);
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 100;
}

.background-btn:hover {
    background: rgba(100, 180, 255, 0.95);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(100, 200, 255, 0.5);
}

/* 背景选择模态框 */
.bg-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    animation: fadeIn 0.3s ease-out;
}

.bg-modal.hidden {
    display: none;
}

.bg-modal-content {
    background: rgba(20, 20, 40, 0.98);
    border-radius: 15px;
    padding: 25px;
    max-width: 900px;
    width: 95%;
    max-height: 85vh;
    border: 2px solid rgba(100, 150, 255, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

.bg-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(100, 150, 255, 0.3);
    padding-bottom: 15px;
}

.bg-modal-header h3 {
    color: #00aaff;
    font-size: 20px;
    margin: 0;
}

.bg-modal-close {
    background: none;
    border: none;
    color: #00aaff;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.bg-modal-close:hover {
    color: #ffffff;
    transform: scale(1.2);
}

/* 背景网格 */
.bg-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    overflow-y: auto;
    padding-right: 10px;
}

/* 背景网格项 */
.bg-item {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(100, 150, 255, 0.3);
    transition: all 0.25s ease;
    background-size: cover;
    background-position: center;
}

.bg-item:hover {
    transform: scale(1.05);
    border-color: rgba(100, 200, 255, 0.8);
    box-shadow: 0 0 15px rgba(100, 200, 255, 0.4);
}

.bg-item.selected {
    border-color: rgba(100, 255, 100, 0.8);
    box-shadow: 0 0 20px rgba(100, 255, 100, 0.5);
}

.bg-item-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 8px;
    font-size: 14px;
    text-align: center;
    transition: all 0.25s ease;
}

.bg-item:hover .bg-item-label {
    background: rgba(0, 0, 0, 0.9);
}

/* 响应式设计 */
@media (max-width: 600px) {
    .bg-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .bg-modal-content {
        max-height: 90vh;
        padding: 15px;
    }

    .background-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
        bottom: 80px;
        left: 15px;
    }
}

/* 原有响应式设计 */
@media (max-width: 600px) {
    .chat-container {
        max-width: 100%;
        height: 85vh;
    }

    .avatar {
        width: 50px;
        height: 50px;
    }

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

    .send-button {
        width: 60px;
        font-size: 12px;
    }

    .message-input {
        font-size: 14px;
    }
}
