/* Variables */
:root {
    /* 这些变量会被 COLOR_SCHEMES (app.js) 动态覆盖 */
    --primary-color: #ff758c;
    --secondary-color: #ff7eb3;
    --bg-color: #2b1055;
    --bg-gradient-end: #7597de;
    --sidebar-bg: rgba(255, 255, 255, 0.95);
    --text-main: #4a4a4a;
    --text-secondary: #888888;
    --border-color: #ffd1d1;

    --happy-color: var(--happy-color, #ff9a9e);
    --sad-color: #a18cd1;
    --question-color: #fad0c4;
    --neutral-color: #d4fc79;

    --glass-opacity: 0.95;
}

/* Reset & Base */
html, body {
    margin: 0;
    padding: 0;
    overflow: hidden; /* 禁止页面滚动条 */
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    display: flex;
    height: 100vh;
    background: linear-gradient(135deg, var(--bg-color) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-main);
    transition: background 0.3s ease, color 0.3s ease;
}

/* Experience Overlays (Intro/Outro) */
.experience-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, rgba(255, 154, 158, 0.15), transparent 40%),
                radial-gradient(circle at 80% 30%, rgba(120, 122, 255, 0.18), transparent 42%),
                linear-gradient(135deg, rgba(10, 8, 30, 0.92), rgba(15, 10, 25, 0.9));
    z-index: var(--z-intro);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.experience-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.experience-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.experience-overlay .overlay-inner {
    max-width: 640px;
    padding: 48px 56px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(16px);
    text-align: left;
    position: relative;
    overflow: hidden;
}

.experience-overlay .overlay-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255, 154, 158, 0.14), transparent 40%),
                radial-gradient(circle at 80% 80%, rgba(132, 250, 176, 0.12), transparent 35%);
    pointer-events: none;
    z-index: var(--z-base);
}

.experience-overlay .overlay-inner > * { position: relative; z-index: var(--z-content); }

.experience-overlay .eyebrow {
    font-size: 12px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--happy-color, #ff9a9e);
    margin-bottom: 12px;
}

.experience-overlay h1 {
    margin: 0 0 16px 0;
    font-size: 36px;
    line-height: 1.2;
    color: var(--text-on-primary, #fff);
    text-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.experience-overlay .subtext {
    margin: 0 0 28px 0;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.8;
    font-size: 15px;
}

.experience-overlay .overlay-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.experience-overlay button {
    padding: 12px 20px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-on-primary, #fff);
    cursor: pointer;
    font-size: 15px;
    transition: all 0.25s ease;
    backdrop-filter: blur(6px);
}

.experience-overlay button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.experience-overlay button.primary {
    background: linear-gradient(120deg, #ff9a9e, #fad0c4);
    border: none;
    color: #2b1055;
    font-weight: 700;
    box-shadow: 0 15px 40px rgba(255, 154, 158, 0.3);
}

.experience-overlay .overlay-glow {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 154, 158, 0.4), transparent 60%);
    filter: blur(40px);
    animation: floatGlow 8s ease-in-out infinite alternate;
    opacity: 0.6;
}

.experience-overlay.hidden { display: none; }

@keyframes floatGlow {
    from { transform: translate(-80px, -40px) scale(1); }
    to { transform: translate(120px, 80px) scale(1.1); }
}

/* Removed duplicate #sidebar definition */
/* Layout */
#message-sidebar {
    width: 380px;
    min-width: 300px;
    max-width: 500px;
    height: 100vh; /* 固定高度为视口高度 */
    /* 🔧 使用主题系统的 CSS 变量，而非旧的 --glass-opacity */
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    /* 🔧 使用主题阴影，支持主题切换 */
    box-shadow: 0 0 20px var(--accent-color, rgba(255, 117, 140, 0.2));
    z-index: var(--z-dropdown);
    backdrop-filter: blur(10px);
    position: relative;
    transition: transform 0.3s ease, background 0.3s;
    overflow: hidden; /* 防止侧边栏本身出现滚动条 */
}

#message-sidebar.collapsed {
    transform: translateX(-100%);
    position: absolute; /* Remove from flow when collapsed */
    height: 100%;
}

/* 折叠按钮样式 - 完全贴合侧边栏边缘 */
.sidebar-collapse-btn {
    position: absolute;
    top: 20px;
    right: 0;
    transform: translateX(50%);
    width: 28px;
    height: 28px;
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 16px;
    transition: all 0.2s;
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-sm);
}

.sidebar-collapse-btn:hover {
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--primary-color);
    color: var(--text-on-primary, #ffffff);
    border-color: var(--primary-color);
    transform: translateX(50%) scale(1.1);
    /* 🔧 使用主题阴影，支持主题切换 */
    box-shadow: 0 4px 12px var(--accent-color, rgba(255, 117, 140, 0.3));
}

/* 侧边栏折叠时，图标旋转 */
#message-sidebar.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

/* 当侧边栏折叠时显示的展开按钮（固定在屏幕左边缘） */
#message-sidebar-toggle-fixed {
    position: fixed;
    left: 0;
    top: 20px;
    width: 28px;
    height: 28px;
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 16px;
    z-index: var(--z-modal); /* 高于侧边栏 */
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

#message-sidebar-toggle-fixed:hover {
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--primary-color);
    color: var(--text-on-primary, #ffffff);
    border-color: var(--primary-color);
    transform: scale(1.1);
    /* 🔧 使用主题阴影，支持主题切换 */
    box-shadow: 0 4px 12px var(--accent-color, rgba(255, 117, 140, 0.3));
}

/* 当侧边栏折叠时显示固定展开按钮 */
body.message-sidebar-collapsed #message-sidebar-toggle-fixed {
    display: flex;
}

/* 当侧边栏折叠时，隐藏侧边栏内的折叠按钮 */
body.message-sidebar-collapsed #message-sidebar .sidebar-collapse-btn {
    display: none;
}

/* Removed old toggle button styles - using new circular design above */

#main-view {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, #1a0b2e 0%, #000000 100%);
    overflow: hidden; /* 防止出现滚动条 */
}

#graph-container {
    flex: 1;
    width: 100%;
    overflow: hidden; /* 防止出现滚动条 */
}

/* Sidebar Header */
#message-sidebar-header { 
    padding: 25px; 
    background: rgba(255, 255, 255, var(--glass-opacity)); 
    border-bottom: 1px solid var(--border-color); 
}

.app-title {
    font-size: 24px;
    font-weight: 300;
    color: var(--code-text, #d63384);
    margin-bottom: 15px;
    display: flex; align-items: center; gap: 10px;
    font-family: 'Georgia', serif;
    letter-spacing: 1px;
    justify-content: center; /* 🔧 让Title居中 */
    text-align: center;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8); /* Improve visibility */
}
.app-title i {
    /* 🔧 使用主题变量，支持主题切换 */
    color: var(--primary-color);
    font-size: 28px;
    /* 🔧 移除硬编码阴影颜色 */
    text-shadow: 0 0 10px var(--accent-color);
}

#stats-bar {
    display: flex;
    justify-content: space-between;
    background: var(--card-bg);
    padding: 12px 15px;
    border-radius: 12px;
    /* 🔧 使用主题边框 */
    border: 1px solid var(--card-border);
}
.stat-item { display: flex; flex-direction: column; align-items: center; }
.stat-val {
    font-size: 18px;
    font-weight: bold;
    /* 🔧 使用主题色 */
    color: var(--primary-color);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}
.stat-label {
    font-size: 11px;
    /* 🔧 使用主题变量 */
    color: var(--text-secondary);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}
#graph-container { flex: 1; width: 100%; }

/* Sidebar Header */
#sidebar-header {
    padding: 25px;
    padding-right: 35px; /* 为折叠按钮留出空间 */
    background: rgba(255, 255, 255, var(--glass-opacity));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: center; /* 竖直居中 */
    position: relative;
    min-height: 120px; /* 确保有足够的高度 */
}

#message-sidebar-header {
    padding: 25px;
    background: rgba(255, 255, 255, var(--glass-opacity));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: center; /* 竖直居中 */
    position: relative;
}

/* Removed duplicate #message-sidebar-header definition */
/* Removed duplicate .app-title definition - keeping the centered version above */

/* Removed duplicate #stats-bar definition */

/* Controls */
#controls {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    /* 🔧 使用主题背景 */
    background: var(--card-hover-bg);
}
.control-label {
    font-size: 12px;
    font-weight: 600;
    /* 🔧 使用主题色 */
    color: var(--primary-color);
    margin-bottom: 10px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}
.filter-group { display: flex; gap: 10px; margin-top: 15px; }

.search-box {
    position: relative;
    margin-bottom: 15px;
}
.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #aaa);
}
#search-input {
    width: 100%;
    padding: 10px 10px 10px 35px;
    /* 🔧 使用主题边框 */
    border: 1px solid var(--card-border);
    border-radius: 20px;
    outline: none;
    font-family: inherit;
    /* 🔧 使用主题文字颜色 */
    color: var(--text-main);
    box-sizing: border-box;
    transition: all 0.3s;
}
#search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(255, 117, 140, 0.2);
}

/* Tabs */
#message-sidebar-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    /* 🔧 使用主题边框 */
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 10px;
}
.tab-btn {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    /* 🔧 使用主题变量 */
    color: var(--text-secondary);
    transition: all 0.3s;
    border-bottom: 2px solid transparent;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}
.tab-btn:hover { color: var(--primary-color); }
.tab-btn.active {
    /* 🔧 使用主题变量，支持主题切换 */
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    /* 🔧 添加背景色，增强选中视觉效果 */
    background: var(--card-hover-bg);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.tab-content { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.tab-content.active { display: flex; }

/* Keyword Ranking */
#keyword-ranking-list { padding: 20px; }
.keyword-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; margin-bottom: 10px;
    /* 🔧 使用主题变量 */
    background: var(--card-bg);
    border-radius: 18px;
    /* 🔧 使用主题边框 */
    border: 1px solid var(--card-border);
    cursor: pointer; transition: all 0.2s;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}
.keyword-item:hover {
    transform: translateX(5px);
    border-color: var(--primary-color);
    /* 🔧 使用主题阴影 */
    box-shadow: 0 2px 8px var(--accent-color, rgba(255, 117, 140, 0.1));
}
.keyword-rank {
    font-weight: bold;
    /* 🔧 使用主题变量 */
    color: var(--text-muted);
    width: 25px;
}
/* 保持排名前三的金属色 */
.keyword-item:nth-child(1) .keyword-rank { color: #ffd700; }
.keyword-item:nth-child(2) .keyword-rank { color: #c0c0c0; }
.keyword-item:nth-child(3) .keyword-rank { color: #cd7f32; }

.keyword-name {
    flex: 1;
    font-weight: 600;
    /* 🔧 使用主题变量 */
    color: var(--text-main);
}
.keyword-count {
    font-size: 12px;
    /* 🔧 使用主题变量 */
    color: var(--text-secondary);
    background: var(--card-hover-bg);
    padding: 2px 8px;
    border-radius: 10px;
}

.filter-btn {
    flex: 1;
    padding: 10px;
    /* 🔧 使用主题边框 */
    border: 1px solid var(--card-border);
    border-radius: 20px;
    /* 🔧 使用主题背景 */
    background: var(--card-bg);
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    /* 🔧 使用主题色 */
    color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
}
.filter-btn:hover {
    /* 🔧 使用主题悬停背景 */
    background: var(--card-hover-bg);
    transform: translateY(-2px);
    /* 🔧 使用主题阴影 */
    box-shadow: 0 4px 10px var(--accent-color, rgba(255, 117, 140, 0.2));
}
.filter-btn.active {
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--primary-color);
    color: var(--text-on-primary, #ffffff);
    border-color: transparent;
    /* 🔧 使用主题阴影，支持主题切换 */
    box-shadow: 0 4px 12px var(--accent-color, rgba(255, 117, 140, 0.4));
}

/* 不同情感的激活状态（统一使用主题色） */
.filter-btn.happy.active {
    background: var(--primary-color);
    color: var(--text-on-primary, #ffffff);
}
.filter-btn.sad.active {
    background: var(--primary-color);
    color: var(--text-on-primary, #ffffff);
}
.filter-btn.question.active {
    background: var(--primary-color);
    color: var(--text-on-primary, #ffffff);
}

/* Chat List */
#chat-list-container {
    flex: 1;
    overflow-y: auto;
    /* 🔧 使用主题变量 */
    background: var(--card-bg);
    position: relative;
}
#chat-list-container::-webkit-scrollbar,
#tab-content-keywords::-webkit-scrollbar { width: 6px; }
#chat-list-container::-webkit-scrollbar-thumb,
#tab-content-keywords::-webkit-scrollbar-thumb {
    /* 🔧 使用主题色 */
    background: var(--primary-color);
    opacity: 0.5;
    border-radius: 3px;
}
#chat-list-content { padding: 20px; }

.message-item { margin-bottom: 25px; display: flex; gap: 15px; cursor: pointer; transition: transform 0.2s; }
.message-item:hover { transform: translateX(5px); }

.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    /* 💡 保留渐变色（视觉设计），但修复阴影 */
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    display: flex; justify-content: center; align-items: center;
    color: white; font-weight: bold; font-size: 14px; flex-shrink: 0;
    /* 🔧 使用主题阴影，支持主题切换 */
    box-shadow: var(--shadow-sm);
}

.msg-body { flex: 1; max-width: 85%; }
.msg-header { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted, #aaa); margin-bottom: 6px; align-items: baseline; }
.sender-name { font-weight: 600; color: var(--code-text, #d63384); }

.msg-bubble {
    padding: 12px 16px; border-radius: 18px; background: var(--card-bg); color: var(--text-main); font-size: 14px; line-height: 1.6;
    position: relative; border-top-left-radius: 4px; word-break: break-word;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03); border: 1px solid var(--card-border);
}
/* 🔧 移除硬编码情感背景色，统一使用主题变量 */
.message-item.happy .msg-bubble { background: var(--card-bg); border-color: var(--card-border); }
.message-item.sad .msg-bubble { background: var(--card-bg); border-color: var(--card-border); }
.message-item.question .msg-bubble { background: var(--card-bg); border-color: var(--card-border); }

.keyword-tag {
    /* 💡 固定文字颜色为白色，确保对比度 */
    color: #ffffff;
    font-weight: 600;
    /* 🔧 使用主题背景 */
    background: var(--primary-color);
    padding: 2px 6px;
    border-radius: 10px;
    margin: 0 2px;
    font-size: 0.9em;
}

/* Overlay info */
#info-overlay { 
    position: absolute; top: 30px; left: 30px; 
    background: rgba(20, 10, 40, 0.8); padding: 25px; border-radius: 16px; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.3); max-width: 320px; 
    display: none; pointer-events: none; backdrop-filter: blur(15px); 
    border: 1px solid rgba(255, 117, 140, 0.3);
    color: white;
    z-index: var(--z-dropdown); /* Ensure above graph but below controls if needed */
}
#info-overlay h3 { margin: 0 0 10px 0; font-size: 20px; color: var(--happy-color, #ff9a9e); display: flex; align-items: center; gap: 10px; font-family: 'Georgia', serif; }
#info-overlay p { margin: 0; font-size: 14px; color: #e0e0e0; line-height: 1.6; }

/* Subtitle Overlay */
#subtitle-overlay {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Georgia', serif;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
    text-align: center;
    pointer-events: none;
    opacity: 0;
    z-index: var(--z-sticky);
    max-width: 70%;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50px;
    backdrop-filter: blur(3px);
    transition: opacity 1s ease-in-out;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: var(--z-overlay);
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

/* 🔧 修复：Toast 使用醒目的深色背景，确保在所有主题下可见 */
.toast {
    /* 🔧 使用深色半透明背景，确保在任何主题下都清晰可见 */
    background: rgba(30, 41, 59, 0.95);
    color: #ffffff;
    padding: 15px 20px;
    border-radius: 12px;
    /* 🔧 增强阴影，提升可见性 */
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 2px 6px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    /* 🔧 使用主题色作为左边框，区分不同类型 */
    border-left: 4px solid var(--primary-color, #667eea);
    /* 🔧 添加外边框增强可见性 */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-left-width: 4px;
    backdrop-filter: blur(12px);
    font-family: "Microsoft YaHei", sans-serif;
    font-size: 14px;
    min-width: 250px;
    animation: slideIn 0.3s ease-out forwards;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    /* 🔧 确保文字清晰可读 */
    font-weight: 500;
}

.toast.success {
    border-left-color: var(--success-color, #10b981);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.95) 0%, rgba(5, 150, 105, 0.95) 100%);
}

.toast.error {
    border-left-color: var(--error-color, #ef4444);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(220, 38, 38, 0.95) 100%);
}

.toast.info {
    border-left-color: var(--info-color, #3b82f6);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.95) 0%, rgba(37, 99, 235, 0.95) 100%);
}

.toast i { font-size: 18px; }
.toast.success i { color: #ffffff; }
.toast.error i { color: #ffffff; }
.toast.info i { color: #ffffff; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}
/* Time Travel Slider */
#time-travel-container {
    position: fixed; /* Changed from absolute to fixed */
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    min-width: 300px; /* Prevent too small */
    max-width: 800px;
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    padding: 15px 30px;
    border-radius: 30px;
    border: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: var(--z-timeline); /* Lower than sidebar (2000) but above graph */
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
}

/* Top Right Controls */
#top-controls {
    position: absolute;
    top: 30px;
    right: 30px;
    display: flex;
    gap: 15px;
    z-index: var(--z-overlay); /* Increased z-index to ensure visibility above everything */
    pointer-events: auto; /* Ensure clickable */
}

#top-controls button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    /* 🔧 使用主题变量，支持主题切换 */
    border: 1px solid var(--primary-color);
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    color: var(--primary-color);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-md);
}

#top-controls button:hover {
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--card-hover-bg);
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent-color, rgba(255, 154, 158, 0.4));
    border-color: var(--primary-color);
}

#top-controls button.active {
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--primary-color);
    color: var(--text-on-primary, #ffffff);
    box-shadow: 0 0 20px var(--accent-color, rgba(255, 154, 158, 0.6));
}

#top-controls.collapsed button:not(#controls-toggle-btn) {
    display: none;
}

#top-controls #controls-toggle-btn {
    width: 36px;
    height: 36px;
    font-size: 18px;
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--card-bg);
    border-color: var(--primary-color);
}

@media (max-width: 768px) {
    #time-travel-container {
        width: 90%;
        bottom: 20px;
        padding: 10px 20px;
        flex-direction: column; /* Stack on mobile */
        gap: 10px;
        border-radius: 20px;
    }
    
    .time-label {
        width: 100%;
        justify-content: center;
    }
    
    #time-slider {
        width: 100%;
    }
}

#time-travel-container:hover {
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--card-hover-bg);
    border-color: var(--primary-color);
}

.time-label {
    /* 🔧 使用主题变量，支持主题切换 */
    color: var(--primary-color);
    font-family: 'Georgia', serif;
    font-size: 18px;
    min-width: 120px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#time-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--card-border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

#time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    /* 🔧 使用主题变量，支持主题切换 */
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--accent-color, rgba(255, 154, 158, 0.8));
    cursor: pointer;
    transition: transform 0.1s;
}

#time-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.time-controls button {
    background: none;
    border: none;
    /* 🔧 使用主题变量，支持主题切换 */
    color: var(--primary-color);
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.time-controls button:hover {
    background: rgba(255, 154, 158, 0.1);
    transform: scale(1.1);
}

/* Loading */
#loading { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: radial-gradient(circle at center, #2b1055 0%, #000000 100%); 
    display: flex; justify-content: center; align-items: center; z-index: var(--z-fixed); flex-direction: column; 
    color: var(--happy-color, #ff9a9e);
}
.spinner { 
    width: 60px; height: 60px; 
    border: 4px solid rgba(255, 154, 158, 0.3); 
    border-top: 4px solid #ff9a9e; 
    border-radius: 50%; 
    animation: spin 1.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite; 
    margin-bottom: 20px; 
    box-shadow: 0 0 20px rgba(255, 154, 158, 0.4);
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ========== Demo 运行指示器 ========== */

.demo-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-above-timeline);
    pointer-events: none;
}

.demo-indicator.hidden {
    display: none;
}

.demo-indicator-content {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    /* 🔧 使用主题渐变背景 */
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: demoBlink 2s ease-in-out infinite;
}

@keyframes demoBlink {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

.demo-icon {
    font-size: 20px;
    color: #ffffff;
    animation: demoPulse 1.5s ease-in-out infinite;
}

@keyframes demoPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.demo-text {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.demo-pulse {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50px;
    background: inherit;
    opacity: 0.5;
    animation: demoRipple 2s ease-out infinite;
    z-index: -1;
}

@keyframes demoRipple {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* ==================== 自定义滚动条样式 ==================== */

/* 侧边栏内容区域的滚动条 */
#tab-content-messages::-webkit-scrollbar,
#keyword-ranking-list::-webkit-scrollbar,
#message-sidebar::-webkit-scrollbar,
#chat-list-content::-webkit-scrollbar {
    width: 6px;
}

#tab-content-messages::-webkit-scrollbar-track,
#keyword-ranking-list::-webkit-scrollbar-track,
#message-sidebar::-webkit-scrollbar-track,
#chat-list-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

#tab-content-messages::-webkit-scrollbar-thumb,
#keyword-ranking-list::-webkit-scrollbar-thumb,
#message-sidebar::-webkit-scrollbar-thumb,
#chat-list-content::-webkit-scrollbar-thumb {
    background: rgba(255, 117, 140, 0.3);
    border-radius: 3px;
}

#tab-content-messages::-webkit-scrollbar-thumb:hover,
#keyword-ranking-list::-webkit-scrollbar-thumb:hover,
#message-sidebar::-webkit-scrollbar-thumb:hover,
#chat-list-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 117, 140, 0.5);
}

/* Firefox 滚动条样式 */
#tab-content-messages,
#keyword-ranking-list,
#message-sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 117, 140, 0.3) rgba(255, 255, 255, 0.1);
}

/* ========== 闲置模式样式 ========== */
body.idle-mode {
    /* 降低UI透明度，营造"睡眠"效果 */
    --glass-opacity: 0.3;
}

body.idle-mode #message-sidebar {
    /* 左侧消息侧边栏淡出 */
    opacity: 0.6;
    transition: opacity 1s ease-in-out;
}

body.idle-mode #sidebar {
    /* 右侧功能侧边栏淡出 */
    opacity: 0.5;
    transition: opacity 1s ease-in-out;
}

body.idle-mode #time-travel-container {
    /* 时空旅行轴淡出 */
    opacity: 0.5;
    transition: opacity 1s ease-in-out;
}

body.idle-mode .toast {
    /* Toast提示保持可见，但稍微透明 */
    opacity: 0.9;
}

/* ========== 闲置模式下的折叠按钮 ========== */
body.idle-mode #message-sidebar-toggle-fixed {
    /* 确保折叠按钮在闲置模式下也能正确显示 */
    opacity: 0.7;
    transition: opacity 1s ease-in-out;
    z-index: var(--z-top); /* 确保在所有元素之上 */
}

/* 闲置模式指示器（可选） */
body.idle-mode::after {
    content: '💤 闲置漫游中';
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 8px 16px;
    /* 🔧 使用主题渐变色背景 */
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    /* 🔧 使用主题变量，确保文字可见性 */
    color: var(--text-on-primary, #ffffff);
    border-radius: 20px;
    font-size: 14px;
    z-index: var(--z-fixed);
    animation: fadeIn 0.5s ease-out;
    pointer-events: none;
    /* 🔧 添加阴影增强可见性 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 恢复正常模式时的淡入效果 */
body:not(.idle-mode) #message-sidebar {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

body:not(.idle-mode) #message-sidebar-toggle-fixed {
    /* 恢复正常模式时，折叠按钮完全不透明 */
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

body:not(.idle-mode) #sidebar {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

body:not(.idle-mode) #time-travel-container {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

/* ========== 移动端响应式设计 ========== */

/* 平板设备 (≤768px) */
@media (max-width: 768px) {
    /* 侧边栏优化 */
    #message-sidebar {
        width: 320px;
        min-width: 280px;
        max-width: 100%;
    }

    /* 统计栏优化 */
    #stats-bar {
        padding: 10px 12px;
        border-radius: 10px;
    }

    .stat-val {
        font-size: 16px;
    }

    .stat-label {
        font-size: 10px;
    }

    /* 顶部控制按钮 */
    #top-controls {
        top: 15px;
        right: 15px;
        gap: 10px;
    }

    #top-controls button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    /* 应用标题 */
    .app-title {
        font-size: 20px;
    }

    /* 搜索框 */
    #search-input {
        padding: 8px 8px 8px 32px;
        font-size: 14px;
    }

    /* 关键词列表 */
    .keyword-item {
        padding: 10px 12px;
    }

    .keyword-name {
        font-size: 14px;
    }

    /* 消息气泡 */
    .msg-bubble {
        padding: 10px 14px;
        font-size: 13px;
    }

    /* Toast 通知 */
    #toast-container {
        left: 20px;
        right: 20px;
        bottom: 10px;
    }

    .toast {
        min-width: auto;
        width: 100%;
        font-size: 13px;
    }

    /* ========== 平板设备闲置模式优化 ========== */
    body.idle-mode #message-sidebar-toggle-fixed {
        /* 平板闲置模式下，折叠按钮保持可见性 */
        opacity: 0.7;
        z-index: var(--z-top);
    }

    body.message-sidebar-collapsed #message-sidebar-toggle-fixed {
        /* 确保折叠按钮在侧边栏折叠时正确显示 */
        display: flex;
        opacity: 0.9;
    }
}

/* 手机设备 (≤480px) */
@media (max-width: 480px) {
    /* 侧边栏变为全屏抽屉 */
    #message-sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        position: fixed;
        left: 0;
        top: 0;
        z-index: var(--z-modal);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    #message-sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    /* 侧边栏头部 */
    #message-sidebar-header {
        padding: 15px;
        min-height: 100px;
    }

    /* 应用标题 */
    .app-title {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .app-title i {
        font-size: 24px;
    }

    /* 统计栏 - 简化布局 */
    #stats-bar {
        padding: 8px 10px;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .stat-item {
        min-width: 60px;
    }

    .stat-val {
        font-size: 14px;
    }

    .stat-label {
        font-size: 9px;
    }

    /* 顶部控制按钮 - 缩小并调整位置 */
    #top-controls {
        top: 10px;
        right: 10px;
        gap: 8px;
    }

    #top-controls button {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    #top-controls #controls-toggle-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    /* 时间轴容器 - 已在708-726行定义，这里补充优化 */
    #time-travel-container {
        width: 95%;
        min-width: unset;
        padding: 12px 15px;
        gap: 8px;
        border-radius: 15px;
    }

    .time-label {
        font-size: 14px;
        min-width: unset;
    }

    /* 搜索框 */
    .search-box {
        margin-bottom: 12px;
    }

    #search-input {
        padding: 10px 10px 10px 36px;
        font-size: 14px;
        border-radius: 18px;
    }

    /* 搜索图标 */
    .search-box i {
        left: 10px;
        font-size: 14px;
    }

    /* 标签页按钮 */
    .tab-btn {
        padding: 6px;
        font-size: 13px;
    }

    /* 关键词列表 */
    #keyword-ranking-list {
        padding: 15px;
    }

    .keyword-item {
        padding: 8px 10px;
        margin-bottom: 8px;
        border-radius: 14px;
    }

    .keyword-rank {
        width: 20px;
        font-size: 14px;
    }

    .keyword-name {
        font-size: 13px;
    }

    .keyword-count {
        font-size: 11px;
        padding: 2px 6px;
    }

    /* 过滤按钮 */
    .filter-btn {
        padding: 8px;
        font-size: 16px;
    }

    /* 消息列表 */
    #chat-list-content {
        padding: 15px;
    }

    .message-item {
        margin-bottom: 15px;
        gap: 10px;
    }

    .avatar {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }

    .msg-bubble {
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 14px;
        border-top-left-radius: 4px;
    }

    .msg-header {
        font-size: 11px;
    }

    /* 信息覆盖层 */
    #info-overlay {
        top: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
        padding: 15px;
        border-radius: 12px;
    }

    #info-overlay h3 {
        font-size: 18px;
    }

    #info-overlay p {
        font-size: 13px;
    }

    /* 副标题覆盖层 */
    #subtitle-overlay {
        font-size: 18px;
        bottom: 20%;
        padding: 10px 20px;
        max-width: 85%;
    }

    /* Toast 通知 */
    #toast-container {
        left: 10px;
        right: 10px;
        bottom: 80px; /* 避开时间轴 */
    }

    .toast {
        padding: 12px 15px;
        font-size: 13px;
        border-radius: 10px;
    }

    .toast i {
        font-size: 16px;
    }

    /* 体验覆盖层 */
    .experience-overlay .overlay-inner {
        max-width: 90%;
        padding: 30px 25px;
        border-radius: 20px;
    }

    .experience-overlay h1 {
        font-size: 28px;
    }

    .experience-overlay .subtext {
        font-size: 14px;
    }

    .experience-overlay button {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* 侧边栏折叠按钮 */
    .sidebar-collapse-btn {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }

    #message-sidebar-toggle-fixed {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }

    /* ========== 移动端闲置模式优化 ========== */
    body.idle-mode #message-sidebar-toggle-fixed {
        /* 移动端闲置模式下，折叠按钮稍微缩小但保持可见 */
        width: 20px;
        height: 20px;
        font-size: 12px;
        top: 15px; /* 调整位置避免与其他元素重叠 */
        opacity: 0.6;
        z-index: var(--z-top); /* 确保在所有元素之上 */
    }

    /* 移动端闲置模式下，固定按钮的位置不受影响 */
    body.message-sidebar-collapsed #message-sidebar-toggle-fixed {
        display: flex;
        opacity: 0.8;
    }
}

/* 小屏手机 (≤375px) */
@media (max-width: 375px) {
    /* 应用标题进一步缩小 */
    .app-title {
        font-size: 16px;
    }

    .app-title i {
        font-size: 20px;
    }

    /* 统计值 */
    .stat-val {
        font-size: 12px;
    }

    .stat-label {
        font-size: 8px;
    }

    /* 顶部控制按钮 */
    #top-controls button {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    /* 关键词 */
    .keyword-name {
        font-size: 12px;
    }

    .keyword-count {
        font-size: 10px;
        padding: 1px 5px;
    }

    /* 消息气泡 */
    .msg-bubble {
        font-size: 12px;
        padding: 8px 10px;
    }

    /* 时间轴 */
    .time-label {
        font-size: 12px;
    }
}

/* 触摸设备优化 - 增大触摸区域 */
@media (hover: none) and (pointer: coarse) {
    /* 按钮、链接等交互元素最小尺寸 44x44px */
    .filter-btn,
    .tab-btn,
    .keyword-item,
    .message-item,
    #top-controls button {
        min-height: 44px;
        min-width: 44px;
    }

    /* 禁用hover效果 */
    .filter-btn:hover,
    .keyword-item:hover,
    .message-item:hover,
    #top-controls button:hover {
        transform: none;
    }

    /* 使用active状态代替hover */
    .filter-btn:active,
    .keyword-item:active,
    .message-item:active,
    #top-controls button:active {
        transform: scale(0.98);
        opacity: 0.8;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    /* 时间轴移到顶部避免遮挡 */
    #time-travel-container {
        bottom: auto;
        top: 60px;
        width: 50%;
        padding: 8px 20px;
    }

    /* 侧边栏缩小高度 */
    #message-sidebar-header {
        padding: 15px;
        min-height: 80px;
    }

    /* Toast 通知位置调整 */
    #toast-container {
        bottom: 10px;
    }
}

