/* 通用 Body 样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: #059669;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background-color: #059669;
    background-image: linear-gradient(135deg, #10b981 0%, #059669 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-size: 17px;
    color: #333;
    position: relative;
    overflow-x: hidden;
}

body[data-page="welcome"],
body[data-page="login"] {
    background-color: #059669;
    background-image: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* 动态背景装饰 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(16, 185, 129, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(34, 197, 94, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    z-index: -1;
    animation: backgroundFloat 20s ease-in-out infinite;
}

@keyframes backgroundFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(1deg); }
}

/* 站点通用顶栏 */
.site-top-bar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    height: 60px;
    width: 100%;
    z-index: 1000;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.site-top-logo {
    height: 36px;
    width: auto;
    margin-right: 12px;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.site-top-logo:hover {
    transform: scale(1.05);
}

.site-top-name {
    font-size: 1.2em;
    font-weight: 600;
    color: #2c3e50;
    background: linear-gradient(135deg, #10b981, #059669);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 欢迎页面特定样式 */
.welcome-page-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    width: 100%;
}

.homepage-content {
    text-align: center;
    max-width: 700px;
    width: 100%;
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 60px 40px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeInScale 0.8s ease-out;
}

.logo-container {
    margin-bottom: 50px;
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.welcome-logo {
    max-width: 400px;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.15));
    transition: transform 0.3s ease;
}

.welcome-logo:hover {
    transform: scale(1.02);
}

.chat-now-button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 18px 40px;
    border-radius: 50px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    display: inline-block;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 8px 25px rgba(16, 185, 129, 0.4),
        0 0 0 0 rgba(16, 185, 129, 0.4);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chat-now-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.chat-now-button:hover::before {
    left: 100%;
}

.chat-now-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 15px 35px rgba(16, 185, 129, 0.6),
        0 0 0 10px rgba(16, 185, 129, 0.1);
}

.chat-now-button:active {
    transform: translateY(-1px) scale(1.02);
}

/* 聊天页面包裹层 */
.chat-page-wrapper {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    padding: 20px;
    width: 100%;
    overflow-y: auto;
}

/* 聊天页面容器 */
.chat-page-container {
    max-width: 1000px;
    width: 100%;
    margin: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    overflow: hidden;
    animation: slideInUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 60px - 40px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-page-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 0 24px;
    display: flex;
    align-items: center;
    min-height: 70px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    width: 100%;
}

.chat-page-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.chat-back-link {
    font-size: 2em;
    color: white;
    text-decoration: none;
    padding: 12px 15px 12px 0;
    transition: all 0.3s ease;
    border-radius: 50%;
}

.chat-back-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-3px);
}

.chat-page-header h1 {
    font-size: 1.3em;
    color: white;
    margin: 0;
    text-align: center;
    flex-grow: 1;
    padding-right: 60px;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.chat-static-welcome {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 24px 28px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    color: #495057;
    line-height: 1.7;
    font-size: 1em;
    position: relative;
    overflow: hidden;
}

.chat-static-welcome::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, #10b981, #059669);
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px 28px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    position: relative;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 3px;
}

.message {
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    animation: messageSlideIn 0.5s ease-out;
    clear: both;
}

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

.message.user-message {
    justify-content: flex-end;
    float: right;
    margin-left: auto;
}

.message.assistant-message {
    justify-content: flex-start;
    float: left;
    margin-right: auto;
}

.message-content {
    max-width: 75%;
    padding: 16px 24px;
    border-radius: 24px;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 1.05em;
    position: relative;
    transition: all 0.3s ease;
}

.message-content:hover {
    transform: translateY(-1px);
}

.assistant-message .message-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    color: #374151;
    border-bottom-left-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.1);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.5);
}

.user-message .message-content {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-bottom-right-radius: 8px;
    box-shadow: 
        0 4px 15px rgba(16, 185, 129, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

.typing-indicator {
    display: none;
    padding: 16px 24px;
    background: linear-gradient(135deg, #f0f2f5 0%, #ffffff 100%);
    border-radius: 24px;
    border-bottom-left-radius: 8px;
    max-width: fit-content;
    margin-bottom: 24px;
    margin-left: 28px;
    float: left;
    clear: both;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.1);
}

.typing-dots {
    display: flex;
    gap: 6px;
}

.typing-dot {
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.7;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

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

.chat-input-area {
    padding: 20px 28px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    position: relative;
}

.chat-input-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.2), transparent);
}

.chat-input-area textarea {
    flex: 1;
    border: 2px solid rgba(16, 185, 129, 0.2);
    border-radius: 25px;
    padding: 16px 20px;
    font-size: 1.05em;
    outline: none;
    transition: all 0.3s ease;
    resize: none;
    min-height: 28px;
    line-height: 1.6;
    max-height: 120px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

.chat-input-area textarea:focus {
    border-color: #10b981;
    box-shadow: 
        0 0 0 3px rgba(16, 185, 129, 0.1),
        0 4px 15px rgba(16, 185, 129, 0.2);
    background: rgba(255, 255, 255, 1);
}

.chat-input-area button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 0 28px;
    height: 56px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 1.05em;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    position: relative;
    overflow: hidden;
}

.chat-input-area button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.chat-input-area button:hover::before {
    left: 100%;
}

.chat-input-area button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.chat-input-area button:active {
    transform: translateY(0);
}

.chat-input-area button:disabled {
    background: linear-gradient(135deg, #9ca3af, #6b7280);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.welcome-footer, .chat-footer {
    text-align: center;
    padding: 24px 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
}

.chat-footer p, .welcome-footer p {
    margin: 6px 0;
}

/* 动画定义 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 40px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 60px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

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

/* 响应式调整 */
@media (max-width: 1000px) {
    .chat-page-wrapper {
        padding: 10px;
    }
    .chat-page-container {
        max-width: 100%;
        margin: 0;
        border-radius: 12px;
        height: calc(100vh - 60px - 20px);
        max-height: calc(100vh - 60px - 20px);
    }
}

@media (max-width: 768px) {
    body { font-size: 16px; }

    body[data-page="welcome"],
    body[data-page="login"] {
        background-color: #059669;
        background-image: linear-gradient(145deg, #10b981 0%, #047857 100%);
    }

    body[data-page="welcome"]::before,
    body[data-page="login"]::before {
        z-index: 0;
    }

    body[data-page="welcome"] > *,
    body[data-page="login"] > * {
        position: relative;
        z-index: 1;
    }
    
    .site-top-bar {
        height: 56px;
        padding: 8px 16px;
    }
    
    .site-top-logo {
        height: 32px;
    }

    .homepage-content {
        background: linear-gradient(145deg, rgba(6, 95, 70, 0.88), rgba(5, 150, 105, 0.78));
        border-color: rgba(255, 255, 255, 0.28);
        padding: 40px 24px;
        margin: 20px;
    }

    .welcome-logo {
        max-width: 280px;
    }
    
    .chat-now-button {
        padding: 16px 32px;
        font-size: 1em;
    }

    .chat-page-header {
        min-height: 60px;
        padding: 0 16px;
    }
    
    .chat-page-header h1 {
        font-size: 1.15em;
        padding-right: 40px;
    }
    
    .chat-back-link {
        font-size: 1.8em;
    }
    
    .chat-static-welcome {
        padding: 20px;
        font-size: 0.95em;
    }
    
    .chat-messages {
        padding: 20px 16px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 14px 20px;
        font-size: 1em;
    }
    
    .typing-indicator {
        padding: 14px 20px;
        margin-left: 16px;
    }

    .chat-input-area {
        padding: 16px;
        gap: 12px;
    }
    
    .chat-input-area textarea {
        padding: 14px 18px;
        font-size: 1em;
        min-height: 26px;
    }
    
    .chat-input-area button {
        padding: 0 24px;
        height: 52px;
        font-size: 1em;
    }
    
    .welcome-footer, .chat-footer {
        padding: 20px 16px;
        font-size: 13px;
    }
}

.error-message.message-content {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%) !important;
    color: #dc2626 !important;
    border: 1px solid #fca5a5 !important;
}

.loading-message.message-content {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%) !important;
    color: #059669 !important;
    border: 1px solid #86efac !important;
}

/* OpenTCM 2026 multilingual + source-aware UI */
.site-top-spacer {
    flex: 1;
}

.language-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.lang-btn {
    min-width: 38px;
    height: 32px;
    border: 1px solid rgba(16, 185, 129, 0.22);
    background: #fff;
    color: #065f46;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn:hover,
.lang-btn.active {
    background: #10b981;
    color: #fff;
    border-color: #10b981;
}

.logout-link {
    color: #065f46;
    text-decoration: none;
    font-weight: 600;
    margin-left: 14px;
    white-space: nowrap;
}

.opentcm-panel {
    max-width: 860px;
}

.welcome-info h1 {
    color: rgba(255,255,255,0.96);
    font-size: 2.1em;
    font-weight: 700;
    margin-bottom: 18px;
    text-shadow: 0 4px 8px rgba(0,0,0,0.18);
}

.welcome-info p {
    color: rgba(255,255,255,0.88);
    font-size: 1.08em;
    line-height: 1.75;
    margin: 0 auto 34px;
    max-width: 720px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.opentcm-feature-row {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 34px;
    flex-wrap: wrap;
}

.feature-item {
    background: rgba(255,255,255,0.16);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 18px 16px;
    width: 160px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.92);
    font-weight: 600;
}

.feature-icon {
    width: 42px;
    height: 42px;
    margin: 0 auto 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.92);
    color: #047857;
    font-size: 1.35em;
    font-weight: 800;
}

.guide-links {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.guide-links a {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.65);
}

.welcome-tip {
    margin-top: 30px;
    padding: 18px 20px;
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.22);
}

.welcome-tip p {
    color: rgba(255,255,255,0.86);
    font-size: 0.95em;
    line-height: 1.6;
    margin: 0;
}

.auth-page-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-panel {
    width: min(440px, 100%);
    background: rgba(255,255,255,0.96);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 8px;
    padding: 36px;
    box-shadow: 0 18px 40px rgba(0,0,0,0.14);
    text-align: left;
}

.auth-logo {
    width: 64px;
    height: auto;
    display: block;
    margin-bottom: 18px;
}

.auth-panel h1 {
    color: #064e3b;
    font-size: 1.7em;
    margin-bottom: 8px;
}

.auth-panel p {
    color: #4b5563;
    line-height: 1.6;
}

.auth-form {
    margin-top: 24px;
}

.auth-form label {
    display: block;
    color: #374151;
    font-weight: 700;
    margin-bottom: 8px;
}

.password-input {
    width: 100%;
    height: 48px;
    border: 2px solid rgba(16, 185, 129, 0.24);
    border-radius: 8px;
    padding: 0 14px;
    font-size: 1em;
    outline: none;
}

.password-input:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.auth-error {
    color: #b91c1c !important;
    background: #fee2e2;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 12px;
}

.auth-submit {
    width: 100%;
    border-radius: 8px;
    margin-top: 18px;
}

.status-indicator {
    position: absolute;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.9);
    font-size: 0.85em;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #a7f3d0;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.welcome-message-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.assistant-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #10b981, #047857);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 0.82em;
    flex-shrink: 0;
}

.welcome-message-title {
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}

.welcome-message-body {
    line-height: 1.7;
}

.chat-mode-row {
    display: flex;
    justify-content: center;
    margin: 14px 0 8px;
}

.chat-input-shell {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-input-shell textarea {
    width: 100%;
    padding-right: 50px;
}

.answer-mode-switch {
    display: flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    padding: 3px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 8px;
    background: #f8fafc;
    box-shadow: 0 8px 24px rgba(15, 118, 110, 0.08);
}

.answer-mode-switch .mode-btn {
    height: 34px;
    padding: 0 16px;
    min-width: 94px;
    border-radius: 6px;
    background: transparent;
    color: #047857;
    box-shadow: none;
    border: 0;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.answer-mode-switch .mode-btn.active {
    background: #059669;
    color: #ffffff;
}

.answer-mode-switch .mode-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.quick-questions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    padding: 16px;
    margin-bottom: 8px;
    display: none;
    border: 1px solid rgba(16, 185, 129, 0.2);
    z-index: 20;
}

.quick-title {
    font-size: 0.9em;
    color: #6b7280;
    margin-bottom: 12px;
    font-weight: 600;
}

.quick-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#quickQuestionsToggle {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.08);
    color: #047857;
    box-shadow: none;
}

.assistant-content-wrapper {
    width: min(820px, calc(100% - 48px));
}

.thinking-container {
    background: #f0fdf4;
    border: 1px solid rgba(16, 185, 129, 0.22);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(5, 150, 105, 0.08);
}

.thinking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(14, 165, 233, 0.08));
    border-bottom: 1px solid rgba(16, 185, 129, 0.16);
}

.thinking-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #065f46;
    font-weight: 800;
    font-size: 0.92em;
}

.thinking-icon,
.final-answer-icon {
    min-width: 30px;
    height: 24px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #fff;
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-size: 0.78em;
    font-weight: 900;
}

.thinking-toggle {
    border: none;
    background: rgba(255,255,255,0.8);
    color: #047857;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-weight: 800;
}

.thinking-content {
    padding: 14px 16px;
    max-height: 330px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.thinking-step {
    padding: 12px 0;
    border-bottom: 1px dashed rgba(16, 185, 129, 0.25);
}

.thinking-step:last-child {
    border-bottom: none;
}

.thinking-step-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #047857;
    font-weight: 750;
    margin-bottom: 8px;
}

.step-number {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #10b981;
    color: #fff;
    font-size: 0.78em;
    font-weight: 900;
    flex-shrink: 0;
}

.step-title-text {
    font-size: 0.92em;
}

.thinking-step-content {
    color: #374151;
    font-size: 0.9em;
    line-height: 1.72;
    padding-left: 30px;
    word-break: break-word;
}

.standard-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 10px 14px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 8px;
    background: #f0fdf4;
    color: #065f46;
    font-size: 0.94em;
    font-weight: 750;
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.08);
}

.standard-status-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(5, 150, 105, 0.22);
    border-top-color: #059669;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.final-answer-container {
    background: #fff;
    border: 1px solid rgba(16, 185, 129, 0.22);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.final-answer-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px 16px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(245, 158, 11, 0.09));
    border-bottom: 1px solid rgba(16, 185, 129, 0.14);
    color: #064e3b;
    font-weight: 850;
}

.final-answer-content {
    padding: 18px 20px;
    line-height: 1.78;
    color: #1f2937;
    font-size: 1em;
    word-break: break-word;
}

.final-answer-content strong {
    color: #064e3b;
}

.streaming-final-answer::after {
    content: "|";
    animation: blink 1s infinite;
    color: #10b981;
    font-weight: 400;
}

.streaming-complete::after {
    display: none;
}

.message.user-message,
.message.assistant-message {
    float: none;
    clear: both;
    width: 100%;
}

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

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

.citation-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 24px;
    margin: 0 2px;
    padding: 0 8px;
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font-weight: 800;
    cursor: pointer;
    font-size: 0.82em;
    vertical-align: baseline;
}

.citation-chip:hover {
    background: #10b981;
    color: #fff;
}

.source-popover {
    position: absolute;
    z-index: 2000;
    width: min(520px, calc(100vw - 24px));
    max-height: min(70vh, 620px);
    overflow: auto;
    background: #fff;
    border: 1px solid rgba(16, 185, 129, 0.28);
    border-radius: 8px;
    box-shadow: 0 18px 44px rgba(0,0,0,0.18);
    padding: 16px;
    color: #1f2937;
    line-height: 1.65;
}

.source-popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.source-close {
    border: none;
    background: #f3f4f6;
    color: #374151;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
}

.source-book {
    color: #065f46;
    font-weight: 800;
    margin-bottom: 4px;
}

.source-path {
    color: #6b7280;
    font-size: 0.88em;
    word-break: break-all;
    margin-bottom: 12px;
}

.source-section {
    border-top: 1px solid #e5e7eb;
    padding-top: 10px;
    margin-top: 10px;
}

.source-section ul {
    margin: 6px 0 0 18px;
}

.source-section p {
    margin-top: 6px;
    white-space: pre-wrap;
}

.typing-dots.compact {
    transform: scale(0.6);
}

@media (max-width: 768px) {
    .language-switch {
        gap: 4px;
    }

    .lang-btn {
        min-width: 34px;
        height: 30px;
        font-size: 0.85em;
    }

    .logout-link {
        margin-left: 8px;
        font-size: 0.88em;
    }

    .status-indicator {
        display: none;
    }

    .chat-page-header h1 {
        padding-right: 0;
    }

    .chat-mode-row {
        justify-content: flex-start;
        margin: 10px 0 8px;
    }

    .answer-mode-switch {
        width: 100%;
    }

    .answer-mode-switch .mode-btn {
        flex: 1;
        min-width: 0;
        padding: 0 8px;
        font-size: 13px;
    }

    .chat-input-area {
        align-items: flex-end;
    }

    .chat-input-area button#sendButton {
        padding: 0 16px;
        min-width: 78px;
    }

    .feature-item {
        width: min(190px, 100%);
    }

    .auth-panel {
        padding: 28px 22px;
    }
}
