/* ===== 登录验证 ===== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ff6b9d 0%, #c44569 50%, #f8b500 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header h2 {
    text-align: center;
    color: #ec4899;
    margin-bottom: 5px;
    font-size: 1.5rem;
}

.login-subtitle {
    text-align: center;
    color: #9ca3af;
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
}

.login-form input {
    padding: 15px 20px;
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    background: #fafafa;
}

.login-form input:focus {
    border-color: #ec4899;
    background: white;
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1);
}

.login-error {
    color: #ef4444;
    font-size: 0.875rem;

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
}

.login-form input {
    padding: 15px 20px;
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    background: #fafafa;
}

.login-form input:focus {
    border-color: #ec4899;
    background: white;
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1);
}

.login-error {
    color: #ef4444;
    font-size: 0.875rem;
    text-align: center;
    min-height: 20px;
}

.login-btn {
    padding: 15px;
    background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(236, 72, 153, 0.4);
}

.login-btn:active {
    transform: translateY(0);
}

/* ===== 基础重置 ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(180deg, #fff5f7 0%, #ffe4e8 100%);
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* ===== 聊天容器 ===== */
.chat-container {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-container::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(249, 168, 212, 0.08) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
}

/* ===== 顶部栏 ===== */
.chat-header {
    background: linear-gradient(135deg, #fff0f3, #ffd6e6, #ffc2d1);
    padding: clamp(12px, 3vh, 16px) clamp(10px, 3vw, 16px);
    border-bottom: 1px solid rgba(255, 182, 193, 0.2);
    z-index: 1; display: flex; align-items: center; justify-content: space-between;
}
.chat-header h1 {
    font-size: clamp(16px, 3.5vw, 24px);
    font-weight: 600;
    background: linear-gradient(135deg, #ec4899, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    animation: shimmer 3s ease-in-out infinite;
}
@keyframes shimmer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
/* Role info now inside header-info, see index.html style */

/* ===== 角色选择器 ===== */
.role-selector {
    background: linear-gradient(180deg, #fffafb, #fff5f7);
    border-bottom: 1px solid rgba(255, 182, 193, 0.15);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}
.role-selector.collapsed {
    max-height: clamp(44px, 7vh, 52px);
}
.role-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(10px, 2vh, 14px) clamp(10px, 3vw, 20px);
    cursor: pointer;
    transition: background 0.3s;
}
.role-selector-header:hover { background: rgba(249, 168, 212, 0.1); }
.role-selector-header h3 {
    font-size: clamp(11px, 1.9vw, 13px);
    color: #ec4899;
    font-weight: 600;
}
.toggle-btn {
    width: clamp(20px, 3.5vw, 24px);
    height: clamp(20px, 3.5vw, 24px);
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #fbcfe8, #f9a8d4);
    color: white;
    font-size: clamp(8px, 1.5vw, 10px);
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(249, 168, 212, 0.3);
}
.toggle-btn.collapsed { transform: rotate(180deg); }
.role-selector-content { padding: 0 clamp(8px, 2vw, 16px) clamp(10px, 2vh, 16px); }
.role-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(6px, 1.5vw, 10px);
}

.role-card {
    padding: clamp(8px, 1.5vh, 12px) clamp(6px, 1.5vw, 10px);
    background: white;
    border: 2px solid rgba(255, 182, 193, 0.15);
    border-radius: clamp(10px, 2vw, 16px);
    cursor: pointer;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.role-card::before {
    content: '';
    position: absolute; top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(249, 168, 212, 0.2), transparent);
    transition: left 0.5s;
}
.role-card:hover::before { left: 100%; }
.role-card:hover {
    border-color: #f9a8d4;
    box-shadow: 0 8px 24px rgba(249, 168, 212, 0.3);
    transform: translateY(-4px);
}
.role-card.selected {
    border-color: #ec4899;
    background: linear-gradient(135deg, #fff0f3, #ffe4e8);
    box-shadow: 0 4px 16px rgba(236, 72, 153, 0.2);
}
.role-card .role-name { font-size: clamp(10px, 1.8vw, 14px); font-weight: 600; color: #4b5563; }
.role-card .role-desc { font-size: clamp(9px, 1.5vw, 11px); color: #9ca3af; margin-top: 4px; }
.role-card.custom-role { position: relative; }
.custom-badge {
    display: inline-block;
    font-size: 10px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
    vertical-align: middle;
}
.delete-role-btn {
    position: absolute; top: 4px; right: 4px;
    width: 18px; height: 18px; border-radius: 50%; border: none;
    background: rgba(239, 68, 68, 0.8);
    color: white; font-size: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s;
}
.role-card.custom-role:hover .delete-role-btn { opacity: 1; }
.role-card.add-custom {
    border: 2px dashed #f9a8d4;
    background: rgba(255, 255, 255, 0.6);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.role-card.add-custom:hover { background: #fff0f3; }

/* ===== 消息区域 ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: clamp(10px, 2.5vw, 20px);
    --bg-image: url('bg/2oxy1s.jpg');
    background: 
        linear-gradient(rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.85)),
        var(--bg-image) center/cover no-repeat;
    display: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.chat-messages.show { display: block; }
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: rgba(249, 168, 212, 0.1); border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #fbcfe8, #f9a8d4); border-radius: 3px; }

.message {
    padding: clamp(8px, 1.8vh, 12px) clamp(10px, 2.5vw, 16px);
    border-radius: clamp(14px, 2.5vw, 20px);
    margin-bottom: clamp(8px, 1.5vh, 12px);
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: clamp(12px, 2vw, 15px);
    animation: slideIn 0.4s ease-out;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.message.sent {
    background: linear-gradient(135deg, #fbcfe8, #f9a8d4);
    color: #374151;
    margin-left: auto;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(249, 168, 212, 0.4);
}
.message.received {
    background: white;
    color: #374151;
    margin-right: auto;
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.message-time { font-size: 10px; color: #9ca3af; margin-top: 4px; text-align: right; }

/* ===== 输入栏 ===== */
.chat-input {
    display: flex;
    padding: clamp(6px, 2vh, 16px) clamp(8px, 2.5vw, 20px);
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid rgba(255, 182, 193, 0.15);
    z-index: 1;
    gap: clamp(4px, 1.5vw, 12px);
    flex-shrink: 0;
}
.chat-input input {
    flex: 1;
    padding: clamp(8px, 1.8vh, 14px) clamp(10px, 2.5vw, 20px);
    border: 2px solid rgba(255, 182, 193, 0.2);
    border-radius: clamp(18px, 3vw, 24px);
    outline: none;
    font-size: 16px;
    background: #fffafb;
    transition: all 0.3s;
}
.chat-input input:focus {
    border-color: #f9a8d4;
    background: white;
    box-shadow: 0 0 0 4px rgba(249, 168, 212, 0.15);
}
.chat-input input::placeholder { color: #d1d5db; }
.chat-input button {
    padding: clamp(8px, 1.8vh, 14px) clamp(12px, 3.5vw, 24px);
    background: linear-gradient(135deg, #ec4899, #f472b6);
    color: white;
    border: none;
    border-radius: clamp(18px, 3vw, 24px);
    cursor: pointer;
    font-size: clamp(12px, 2vw, 14px);
    font-weight: 600;
    transition: all 0.35s;
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}
.chat-input button::before {
    content: '';
    position: absolute; top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}
.chat-input button:hover::before { left: 100%; }
.chat-input button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(236, 72, 153, 0.5);
}
.chat-input button:active { transform: translateY(0); }
.chat-input button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ===== 打字动画 ===== */
.typing-indicator {
    display: flex; align-items: center;
    padding: clamp(10px, 1.8vh, 14px) clamp(12px, 2.5vw, 18px);
    background: white;
    border-radius: 20px;
    margin-bottom: 12px;
    max-width: 85%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 6px;
    animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.typing-dots { display: flex; gap: 6px; }
.typing-dots span {
    width: 8px; height: 8px;
    background: linear-gradient(135deg, #fbcfe8, #f9a8d4);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1.2); opacity: 1; }
}

/* ===== 错误消息 ===== */
.error-message {
    background: #fff0f3;
    color: #ec4899;
    padding: clamp(8px, 1.5vh, 12px) clamp(10px, 2vw, 16px);
    border-radius: 12px;
    margin-bottom: 12px;
    text-align: center;
    font-size: clamp(11px, 1.8vw, 13px);
    border: 1px solid #fecdd3;
    animation: shake 0.5s;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.loading { text-align: center; padding: 20px; color: #f9a8d4; font-size: 14px; }

/* ===== 模态框 ===== */
.modal-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(8px);
    justify-content: center; align-items: center;
    z-index: 1000;
}
.modal-overlay.show { display: flex; }
.modal {
    background: white;
    border-radius: clamp(16px, 3vw, 24px);
    padding: clamp(16px, 3vh, 28px);
    width: min(90%, 400px);
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ec4899, #f472b6, #fbcfe8);
    border-radius: 24px 24px 0 0;
}
.modal h2 {
    font-size: clamp(14px, 2.5vw, 18px);
    color: #4b5563;
    margin-bottom: clamp(16px, 3vh, 24px);
    text-align: center;
    font-weight: 600;
}
.modal .form-group { margin-bottom: clamp(10px, 2vh, 16px); }
.modal .form-group label {
    display: block;
    font-size: clamp(11px, 1.8vw, 13px);
    color: #6b7280;
    margin-bottom: 6px;
    font-weight: 600;
}
.modal .form-group input,
.modal .form-group textarea {
    width: 100%;
    padding: clamp(8px, 1.5vh, 12px) clamp(10px, 2vw, 16px);
    border: 2px solid rgba(255, 182, 193, 0.2);
    border-radius: clamp(10px, 2vw, 14px);
    font-size: clamp(12px, 1.9vw, 14px);
    outline: none;
    background: #fffafb;
    transition: all 0.3s;
}
.modal .form-group input:focus,
.modal .form-group textarea:focus {
    border-color: #f9a8d4;
    background: white;
    box-shadow: 0 0 0 4px rgba(249, 168, 212, 0.15);
}
.modal .form-group textarea { min-height: clamp(70px, 12vh, 100px); resize: vertical; }
.modal .form-group .hint { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: clamp(16px, 3vh, 24px); }
.modal .modal-actions button {
    flex: 1;
    padding: clamp(8px, 1.5vh, 12px);
    border: none;
    border-radius: clamp(10px, 1.8vw, 14px);
    font-size: clamp(12px, 1.9vw, 14px);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.35s;
}
.modal .modal-actions .btn-cancel { background: #f3f4f6; color: #6b7280; }
.modal .modal-actions .btn-cancel:hover { background: #e5e7eb; transform: translateY(-2px); }
.modal .modal-actions .btn-confirm {
    background: linear-gradient(135deg, #ec4899, #f472b6);
    color: white;
    box-shadow: 0 4px 16px rgba(236, 72, 153, 0.3);
}
.modal .modal-actions .btn-confirm:hover {
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
    transform: translateY(-2px);
}
.modal .modal-actions .btn-confirm:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== 响应式：桌面端加约束 ===== */
@media (min-width: 768px) {
    body { padding: 16px; }
    .chat-container {
        border-radius: 24px;
        max-width: min(520px, 95vw);
        max-height: min(800px, 95vh);
        box-shadow: 0 20px 60px rgba(252, 182, 193, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.2);
    }
}

/* ===== 响应式：大屏桌面 ===== */
@media (min-width: 1200px) {
    .chat-container { max-width: 540px; max-height: 860px; }
}

/* ===== 响应式：手机端全屏 ===== */
@media (max-width: 767px) {
    .chat-container {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100vw; max-width: 100vw;
        height: 100dvh;
        border-radius: 0;
        overflow-x: hidden;
    }
    .role-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 美观的提示框 ===== */
.toast-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    justify-content: center;
    align-items: center;
    z-index: 3000;
    pointer-events: none;
}

.toast-overlay.show {
    display: flex;
}

.toast {
    background: white;
    border-radius: 20px;
    padding: 28px 36px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    min-width: 260px;
    max-width: 320px;
    transform: scale(0.85) translateY(30px);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-overlay.show .toast {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.toast-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.toast.success .toast-icon {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}

.toast.error .toast-icon {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
}

.toast.warning .toast-icon {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.toast.info .toast-icon {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.toast-message {
    color: #374151;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    line-height: 1.5;
}

.toast.success .toast-message { color: #059669; }
.toast.error .toast-message { color: #dc2626; }
.toast.warning .toast-message { color: #d97706; }
.toast.info .toast-message { color: #2563eb; }

