:root {
    /* Color Palette - Light Mode (from RiceMind Data) */
    --bg-dark: #F8FAFC;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 1);
    
    --accent-green: #059669;
    --accent-green-glow: rgba(5, 150, 105, 0.2);
    --accent-cyan: #0891B2;
    --accent-cyan-glow: rgba(8, 145, 178, 0.2);
    
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    
    --border-color: rgba(0, 0, 0, 0.1);
    
    /* Legacy Mapping for MCP Components */
    --primary-color: var(--accent-green);
    --secondary-color: rgba(5, 150, 105, 0.1);
    --text-color: var(--text-primary);
    --light-text: var(--text-muted);
    --bg-color: var(--bg-dark);
    --chat-bg: rgba(248, 250, 252, 0.5);
    --user-bubble: rgba(8, 145, 178, 0.1);
    --bot-bubble: #ffffff;
    --reasoner-bubble: #f1f5f9;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --sidebar-width: 280px;

    /* Typography */
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    position: relative;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(6, 182, 212, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.08) 0%, transparent 50%);
}

a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-green);
}

/* 侧边栏样式 */
.sidebar {
    width: var(--sidebar-width);
    background-color: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    transform: translateX(0);
}

.sidebar-header {
    padding: 1.2rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-green);
    font-family: var(--font-display);
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--light-text);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.history-item {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
}

.history-item:hover {
    background-color: var(--secondary-color);
}

.history-item.active {
    background-color: var(--secondary-color);
    border-left-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.history-item-title {
    font-weight: 500;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-preview {
    font-size: 0.8rem;
    color: var(--light-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #eee;
    text-align: center;
}

.new-chat-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    width: 100%;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.new-chat-btn:hover {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--accent-green-glow);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    height: calc(100vh - 70px);
    overflow-y: auto;
    padding-top: 20px; /* Reduced from 70px because of fixed header offset */
    margin-top: 70px;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

header {
    background: linear-gradient(135deg, var(--primary-color), #7b4fff);
    color: white;
    padding: 1rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content {
    flex: 1;
}

h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.subtitle {
    font-size: 1.8rem;
    opacity: 0.9;
    font-weight: 300;
}

.menu-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.2);  /* 改为半透明背景 */
    border: none;
    color: lightgray;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background-color 0.2s;
    z-index: 50;
}

.menu-btn:hover {
    background-color: var(--secondary-color);
    color: var(--accent-green);
}

/* =========================================
   Navigation Bar (from RiceMind Data)
   ========================================= */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
}

.brand-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.brand-highlight {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-item {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 0;
    position: relative;
    text-decoration: none;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-cyan);
    transition: width var(--transition-fast);
}

.nav-item:hover::after {
    width: 100%;
}

.nav-item:hover {
    color: var(--text-primary);
}

.nav-divider {
    width: 1px;
    height: 20px;
    background-color: var(--border-color);
}

.nav-item.external {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--accent-green);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    padding: 1rem;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    height: 800px; /* Increased height as requested */
    max-height: calc(100vh - 120px);
    min-height: 600px;
    position: relative;
}

.chat-header {
    background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
    color: white;
    padding: 1rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.clear-history-btn {
    background: none;
    border: none;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.clear-history-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.chat-header .status {
    width: 10px;
    height: 10px;
    background-color: #7ef77e;
    border-radius: 50%;
    margin-right: 8px;
}

.chat-messages {
    flex: 1;
    /* 原来是 padding: 1.5rem; */
    /* 改为：上 1.5rem, 右 1.5rem, 下 0 (紧贴底部), 左 1.5rem */
    padding: 1.5rem 1.5rem 0 1.5rem; 
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    height: 100%;
    min-height: 0;
}

/* 当介绍面板可见时，隐藏或缩小聊天消息区域，让面板占据更多空间 */
.intro-panel:not(.hidden) + .chat-messages {
    flex: 0;
    padding: 0;
}

.message-container {
    display: flex;
    gap: 12px;
    max-width: 90%;
}

.message-container.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    align-self: flex-end;
}

.user-avatar {
    background-color: var(--accent-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.bot-avatar {
    background-color: var(--accent-green);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.reasoner-avatar {
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #777777;
    font-weight: bold;
}

.message {
    max-width: calc(100% - 60px);
    padding: 0.8rem 1.2rem;
    border-radius: 18px;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease-out;
    word-break: break-word;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #eee;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.settings-btn {
    background-color: #f5f0ff;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 0.6rem 1rem;
    border-radius: 4px;
    width: 100%;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.settings-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 设置弹窗样式 */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.settings-modal.active {
    opacity: 1;
    pointer-events: all;
}

.settings-content {
    background-color: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.settings-modal.active .settings-content {
    transform: translateY(0);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.settings-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
}

.close-settings {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--light-text);
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.9rem;
    color: var(--text-color);
    font-weight: 500;
}

.form-input {
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border 0.2s;
}

.form-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary {
    background-color: #f5f5f5;
    color: var(--text-color);
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background-color: #eee;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
    color: white;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--accent-green-glow);
}

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

.user-message {
    background-color: var(--user-bubble);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(8, 145, 178, 0.2);
}

.bot-message {
    background-color: var(--bot-bubble);
    box-shadow: var(--shadow);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.reasoner-message {
    background-color: var(--reasoner-bubble);
    box-shadow: var(--shadow);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.message-time {
    font-size: 0.7rem;
    color: var(--light-text);
    margin-top: 4px;
    text-align: right;
}

.input-area {
    display: flex;
    gap: 0.8rem;
    padding: 1rem;
    background-color: white;
    border-top: 1px solid #eee;
    flex-shrink: 0; /* 防止被挤压 */
    z-index: 20;
}

.message-input {
    flex: 1;
    padding: 0.8rem 1.2rem;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 1rem;
    outline: none;
    transition: border 0.2s;
    resize: none;
    max-height: 120px;
}

.message-input:focus {
    border-color: var(--primary-color);
}

.send-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.send-button:hover {
    background-color: #8860e6;
    transform: scale(1.05);
}

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

.send-icon {
    width: 20px;
    height: 20px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.8rem 1.2rem;
    background-color: var(--bot-bubble);
    border-radius: 18px;
    align-self: flex-start;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: none;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: var(--light-text);
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* =========================================
   Footer (from RiceMind Data)
   ========================================= */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    width: 100%;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .sidebar {
        width: 85%;
    }

    .chat-container {
        height: 75vh;
    }

    .chat-messages {
        padding: 1rem;
    }

    .message {
        max-width: calc(100% - 52px);
    }
    
    .features-grid {
        max-height: 50vh; /* 手机上稍微减小一点 */
    }
}


/* --- Intro Panel Styles (SCROLLABLE UPDATE) --- */
.intro-panel {
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center; 
    align-items: center;
    flex: 1; /* Changed from height: 100% to flex: 1 to share space correctly */
    width: 100%;
    min-height: 0; /* Allow shrinking */
}

.intro-panel h2 {
    color: #333;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 1.6rem;
}

/* 核心修改：Grid 容器支持内部滚动 */
.features-grid {
    display: grid;
    /* 自动填充，卡片最小宽度 220px */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
    width: 100%;
    max-width: 1000px;
    
    /* 限制高度并允许滚动 - 增加到 65vh 以利用更多空间 */
    max-height: 65vh; 
    overflow-y: auto;
    
    /* 内边距，防止阴影或 hover 效果被裁剪 */
    padding: 10px 5px;
    
    /* 滚动条样式 (Standard) */
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

/* Webkit 滚动条美化 (Chrome, Safari, Edge) */
.features-grid::-webkit-scrollbar {
    width: 6px;
}
.features-grid::-webkit-scrollbar-track {
    background: transparent;
}
.features-grid::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 20px;
}
.features-grid::-webkit-scrollbar-thumb:hover {
    background-color: #aaa;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition-smooth);
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.feature-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    border-color: var(--accent-green);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    margin: 5px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-display);
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
    flex-grow: 1;
}

.example-query {
    display: inline-block;
    background: rgba(8, 145, 178, 0.1);
    color: var(--accent-cyan);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: monospace;
    font-weight: 600;
    align-self: flex-start;
}

/* 当 intro-panel 隐藏时的样式类 */
.intro-panel.hidden {
    display: none;
}

/* --- Status Bar Styles --- */
.status-bar {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    padding: 8px 15px;
    font-size: 0.85em;
    font-family: 'Consolas', 'Monaco', monospace; /* 代码字体 */
    color: #555;
    max-height: 100px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

.status-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: bold;
    text-transform: uppercase;
    flex-shrink: 0;
}

.status-badge.info { background-color: #e3f2fd; color: #1565c0; }
.status-badge.success { background-color: #e8f5e9; color: #2e7d32; }
.status-badge.error { background-color: #ffebee; color: #c62828; }
.status-badge.warning { background-color: #fff3e0; color: #ef6c00; }

.status-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-link {
    color: #0277bd;
    text-decoration: none;
}
.status-link:hover { text-decoration: underline; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-2px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cucur_MCP/static/Cucur_MCP/css/styles.css */

/* Token Truncation Warning */
.truncation-warning {
    font-size: 0.8rem;
    color: #c62828; /* Deep red for warning */
    background-color: #ffebee;
    padding: 8px 12px;
    margin-top: 10px;
    border-radius: 6px;
    border: 1px solid #ffcdd2;
    line-height: 1.4;
}

.truncation-warning a {
    color: #d32f2f;
    text-decoration: underline;
    word-break: break-all;
}

.truncation-warning a:hover {
    color: #b71c1c;
}

/* Token Usage Stats */
.token-usage {
    font-size: 0.7rem;
    color: #888;
    margin-top: 8px;
    text-align: right;
    font-family: 'Consolas', monospace;
    padding-top: 6px;
    border-top: 1px dashed #eee;
}