/* ─── 军事预防医学科普平台 · 知识图谱 ─── */
/* ─── CSS 变量与全局 ─────────────────────── */

:root {
    --primary: #0d5238;
    --primary-light: #1a7a54;
    --primary-lighter: #e8f5e9;
    --primary-dark: #073620;
    --accent: #00897b;
    --accent-light: #4db6ac;
    --gold: #c8952e;
    --gold-light: #f9a825;
    --bg: #f0f3f5;
    --bg-card: #ffffff;
    --sidebar-bg: #f8fafc;
    --sidebar-hover: #ecfdf5;
    --sidebar-active: #d1fae5;
    --text: #1e293b;
    --text-secondary: #475569;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── 平台顶部导航 ───────────────────────── */

.platform-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    display: grid;
    grid-template-columns: auto minmax(0, 50vw);
    position: relative;
    z-index: 1000;
    box-shadow: 0 2px 16px rgba(0,0,0,0.18);
    user-select: none;
}

.platform-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
    opacity: 0.7;
}

/* ─── 行布局 ──────────────────────────────── */

.header-row {
    display: contents;
}

.header-row-top {
    display: contents;
}

.header-row-top .platform-brand {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 24px 8px 24px;
}

.header-row-top .top-nav {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    align-items: center;
    padding: 8px 24px 8px 0;
}

.header-row-bottom {
    display: contents;
}

.header-row-bottom::before {
    content: '';
    grid-column: 1;
    grid-row: 2;
    background: rgba(0,0,0,0.15);
    border-top: 1px solid rgba(255,255,255,0.08);
}

.header-row-bottom .category-nav {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    align-items: center;
    background: rgba(0,0,0,0.15);
    border-top: 1px solid rgba(255,255,255,0.08);
    min-height: 40px;
    padding: 0 24px 0 0;
}

/* ─── 品牌标识 ────────────────────────────── */

.platform-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.platform-brand:hover {
    opacity: 1;
}

.platform-logo {
    font-size: 28px;
    color: var(--gold-light);
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.platform-name {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 2px;
    line-height: 1.3;
}

.platform-tagline {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    letter-spacing: 1px;
}

/* ─── 第一行功能导航 ──────────────────────── */

.top-nav {
    /* 样式已由 header grid 控制 */
}

.top-nav > .top-nav-btn,
.top-nav > .top-nav-dropdown {
    min-width: 0;
}

.top-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 8px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    border: none;
    background: none;
}

.top-nav-btn:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.12);
}

/* 蓝色底白色字样式（资源库/知识图谱/智能体） */
.top-nav-btn.top-nav-btn-blue {
    background: #2563EB;
    color: #ffffff;
    font-weight: 600;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(37,99,235,0.3);
}

.top-nav-btn.top-nav-btn-blue:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37,99,235,0.4);
}

.top-nav-btn.top-nav-btn-blue.active {
    background: #1e40af;
    box-shadow: 0 2px 8px rgba(30,64,175,0.4);
}

/* 注册按钮（蓝色实心） */
.top-nav-btn.top-nav-btn-primary {
    background: #2563EB;
    color: #ffffff;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(37,99,235,0.3);
}

.top-nav-btn.top-nav-btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37,99,235,0.4);
}

.top-nav-btn.active {
    color: #ffffff;
    background: rgba(255,255,255,0.18);
    font-weight: 600;
}

.top-nav-sep {
    color: rgba(255,255,255,0.25);
    font-size: 12px;
    margin: 0 2px;
    user-select: none;
}

.top-nav-icon {
    font-size: 14px;
}

/* ─── 智能体下拉菜单 ──────────────────────── */

.top-nav-dropdown {
    position: relative;
    display: flex;
}

.top-nav-dropdown .top-nav-btn {
    width: 100%;
    justify-content: center;
}

.dropdown-arrow {
    font-size: 10px;
    margin-left: 2px;
    transition: transform 0.2s;
}

.top-nav-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.16);
    border: 1px solid var(--border);
    padding: 6px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.25s ease;
    z-index: 2000;
}

.top-nav-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: #eff6ff;
    color: #2563EB;
}

.dropdown-item-icon {
    font-size: 15px;
}

/* ─── 下拉菜单图片预览 ──────────────────── */

.dropdown-item.has-preview {
    position: relative;
}

.preview-indicator {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-light);
    transition: color 0.15s;
}

.dropdown-item.has-preview:hover .preview-indicator {
    color: #2563EB;
}

.dropdown-preview {
    position: absolute;
    left: calc(100% + 8px);
    top: calc(50% + 38px);
    transform: translateY(-50%) scale(0.92);
    width: 240px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    z-index: 3000;
    pointer-events: none;
}

.dropdown-preview img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
}

.dropdown-item.has-preview:hover .dropdown-preview {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) scale(1);
}

/* ─── 第二行分类导航 ──────────────────────── */

.category-nav {
    /* 样式已由 header grid 控制 */
}

.category-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    position: relative;
}

.category-tab:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.06);
}

.category-tab.active {
    color: #ffffff;
    font-weight: 600;
    border-bottom-color: var(--gold-light);
}

/* ─── 知识图谱容器 ───────────────────────── */

.kg-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 92px);
    background: var(--bg);
}

/* ─── 分部选项卡 ─────────────────────────── */

.kg-part-tabs {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px 0;
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}

.kg-part-tabs::-webkit-scrollbar {
    display: none;
}

.part-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    background: none;
    font-family: var(--font);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    position: relative;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.part-tab:hover {
    color: var(--text);
    background: var(--sidebar-hover);
}

.part-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
    background: var(--primary-lighter);
}

.part-num {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: inherit;
    opacity: 0.6;
}

.part-tab.active .part-num {
    opacity: 1;
    color: var(--primary);
}

.part-label {
    font-weight: inherit;
}

.part-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--border-light);
    color: var(--text-light);
    font-weight: 400;
}

.part-stat {
    font-size: 11px;
    color: var(--accent);
    font-weight: 500;
}

.part-tab.active .part-stat {
    color: var(--primary);
}

.part-tab.placeholder {
    opacity: 0.6;
}

/* ─── 布局 ───────────────────────────────── */

.app {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ─── 侧边栏 ────────────────────────────── */

.sidebar {
    width: 300px;
    min-width: 300px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition), width var(--transition), min-width var(--transition);
    z-index: 200;
    position: relative;
}

.sidebar.collapsed {
    margin-left: -300px;
    width: 0;
    min-width: 0;
}

.sidebar-header {
    padding: 20px 20px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.sidebar-subtitle {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 14px;
}

.sidebar-search {
    position: relative;
}

.sidebar-search input {
    width: 100%;
    padding: 9px 14px 9px 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    transition: all var(--transition);
    outline: none;
}

.sidebar-search::before {
    content: '\1F50D';
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    pointer-events: none;
}

.sidebar-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 137, 123, 0.1);
}

.sidebar-search input::placeholder {
    color: var(--text-light);
}

/* ─── 章节导航 ──────────────────────────── */

.chapter-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chapter-nav::-webkit-scrollbar {
    width: 4px;
}

.chapter-nav::-webkit-scrollbar-track {
    background: transparent;
}

.chapter-nav::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.chapter-nav::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.chapter-group {
    padding: 4px 0;
}

.chapter-group-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 8px 20px 4px;
    opacity: 0.7;
}

.chapter-item {
    display: flex;
    align-items: center;
    padding: 9px 20px 9px 16px;
    cursor: pointer;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    position: relative;
    gap: 10px;
}

.chapter-item:hover {
    background: var(--sidebar-hover);
}

.chapter-item.active {
    background: var(--sidebar-active);
    border-left-color: var(--primary);
}

.chapter-item .ch-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all var(--transition);
}

.chapter-item.active .ch-num {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.chapter-item .ch-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chapter-item .ch-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.chapter-item.active .ch-name {
    color: var(--primary-dark);
    font-weight: 600;
}

.chapter-item .ch-meta {
    font-size: 11px;
    color: var(--text-light);
}

.chapter-item.active .ch-meta {
    color: var(--primary-light);
}

.chapter-item.hidden {
    display: none;
}

.no-results {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

/* ─── 侧边栏底部 ────────────────────────── */

.sidebar-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    padding: 12px 16px;
}

.sidebar-stats {
    display: flex;
    justify-content: space-around;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    font-family: var(--font-mono);
}

.stat-label {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
}

/* ─── 主内容区 ──────────────────────────── */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.top-bar {
    height: 50px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    z-index: 100;
    flex-shrink: 0;
}

.menu-toggle {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    padding: 0;
    line-height: 0;
}

.menu-toggle svg {
    flex-shrink: 0;
    pointer-events: none;
}

.menu-toggle:hover {
    background: var(--sidebar-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.breadcrumb {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-count {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--primary-lighter);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 12px;
    white-space: nowrap;
    font-weight: 500;
}

.top-bar-hint {
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
}

.top-bar:hover .top-bar-hint {
    opacity: 1;
}

/* ─── 欢迎页（首页模式）───────────────────── */

.kg-container.home .kg-part-tabs { display: none; }
.kg-container.home .sidebar { display: none; }
.kg-container.home .top-bar { display: none; }
.kg-container.home .app { flex: 1; }
.kg-container.home .main { width: 100%; }
.kg-container.home .iframe-container { flex: 1; }

/* ─── iframe 容器 ────────────────────────── */

.iframe-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-card);
}

.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: none;
}

.iframe-container.loaded iframe {
    display: block;
    flex: 1;
}

/* ─── 加载指示器 ─────────────────────────── */

.iframe-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    z-index: 10;
}

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

/* ─── 欢迎页 ────────────────────────────── */

.welcome {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-align: center;
    padding: 40px;
    background: var(--bg-card);
    transition: opacity 0.2s;
}

.iframe-container.loaded .welcome {
    display: none;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
    color: var(--primary-light);
}

.welcome h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.welcome p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.welcome-intro {
    font-size: 17px;
    color: var(--text-secondary);
    line-height: 2.0;
    margin-bottom: 0;
}

.welcome-features {
    display: flex;
    gap: 16px;
    margin: 24px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.welcome-feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 28px;
    background: var(--primary-lighter);
    border-radius: var(--radius);
    min-width: 160px;
    cursor: pointer;
    transition: all var(--transition);
}

.welcome-feature:hover {
    background: #d1fae5;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.wf-icon {
    font-size: 32px;
}

.wf-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.wf-desc {
    font-size: 13px;
    color: var(--text-light);
    text-align: center;
}

.welcome-hint {
    margin-top: 20px;
    font-size: 14px !important;
    color: var(--text-light) !important;
}

/* ─── 占位面板 ──────────────────────────── */

.placeholder-panel {
    position: absolute;
    top: 92px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 500;
}

.placeholder-content {
    text-align: center;
    padding: 60px;
}

.placeholder-icon {
    font-size: 72px;
    margin-bottom: 20px;
    display: block;
    opacity: 0.6;
}

.placeholder-content h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.placeholder-content p {
    font-size: 15px;
    color: var(--text-light);
}

/* ─── 知识部分占位 ──────────────────────── */

.kg-part-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    flex-direction: column;
    gap: 16px;
}

.kg-part-placeholder .placeholder-icon {
    font-size: 56px;
}

.kg-part-placeholder h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.kg-part-placeholder p {
    font-size: 14px;
    color: var(--text-light);
}

/* ─── 智能体聊天界面 ──────────────────────── */

.chat-container {
    display: flex;
    height: calc(100vh - 92px);
    background: var(--bg);
}

/* 聊天侧边栏 */
.chat-sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition), width var(--transition), min-width var(--transition);
    z-index: 200;
}

.chat-sidebar.collapsed {
    margin-left: -260px;
    width: 0;
    min-width: 0;
}

.chat-sidebar-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.chat-sidebar-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.chat-sidebar-subtitle {
    font-size: 12px;
    color: var(--text-light);
}

.chat-agent-nav {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.chat-agent-nav::-webkit-scrollbar { width: 4px; }
.chat-agent-nav::-webkit-scrollbar-track { background: transparent; }
.chat-agent-nav::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
.chat-agent-nav::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.agent-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.agent-item:hover {
    background: var(--sidebar-hover);
}

.agent-item.active {
    background: var(--sidebar-active);
    border-left-color: var(--primary);
}

.agent-item .agent-icon {
    font-size: 22px;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 1px;
}

.agent-item .agent-info {
    flex: 1;
    min-width: 0;
}

.agent-item .agent-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}

.agent-item.active .agent-name {
    color: var(--primary-dark);
}

.agent-item .agent-desc {
    font-size: 11px;
    color: var(--text-light);
    line-height: 1.4;
}

/* 聊天主区域 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.chat-top-bar {
    height: 50px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

/* 聊天消息区 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* 欢迎提示 */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 40px;
    flex: 1;
}

.chat-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.chat-welcome h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.chat-welcome p {
    font-size: 13px;
    color: var(--text-light);
    max-width: 420px;
    line-height: 1.6;
}

/* 消息气泡 */
.message-row {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.message-row.assistant {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.message-row.user .message-avatar {
    background: var(--primary-lighter);
    color: var(--primary);
}

.message-row.assistant .message-avatar {
    background: #e8f0fe;
    color: #1a73e8;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-row.user .message-bubble {
    background: var(--primary);
    color: #ffffff;
    border-radius: var(--radius) var(--radius-sm) var(--radius) var(--radius);
}

.message-row.assistant .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm) var(--radius) var(--radius) var(--radius);
    color: var(--text);
}

.message-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.message-bubble pre {
    background: var(--primary-dark);
    color: #e2e8f0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    margin: 8px 0;
}

/* 流式输出光标 */
.streaming-cursor::after {
    content: '▊';
    animation: blink 0.8s infinite;
    color: var(--primary);
}

@keyframes blink {
    50% { opacity: 0; }
}

/* 相关问题 */
.related-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.related-question-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-card);
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.related-question-btn:hover {
    background: var(--primary-lighter);
    border-color: var(--primary-light);
}

/* 输入区域 */
.chat-input-area {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
    background: var(--bg);
}

.chat-input-area input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 137, 123, 0.1);
}

.chat-input-area input:disabled {
    background: #f1f5f9;
    color: var(--text-light);
    cursor: not-allowed;
}

.chat-input-area input::placeholder {
    color: var(--text-light);
}

.chat-input-area button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.chat-input-area button:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

.chat-input-area button:disabled {
    background: var(--border);
    cursor: not-allowed;
    transform: none;
}

/* 加载动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typingBounce 1.2s infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* 聊天响应式 */
@media (max-width: 768px) {
    .chat-sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        box-shadow: var(--shadow-lg);
        z-index: 300;
    }
    .chat-sidebar.collapsed {
        margin-left: -260px;
        width: 260px;
        box-shadow: none;
    }
    .message-row {
        max-width: 95%;
    }
}

/* ─── 资源库 Avatar 容器 ────────────────── */

.avatar-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 92px);
    background: var(--bg-card);
    position: relative;
    z-index: 1;
}

.avatar-container .top-bar {
    flex-shrink: 0;
}

.avatar-iframe-wrapper {
    flex: 1;
    overflow: hidden;
}

.avatar-iframe-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ─── 响应式 ────────────────────────────── */

@media (max-width: 900px) {
    .header-row-top {
        padding: 6px 12px;
    }
    .header-row-bottom {
        padding: 0 12px;
    }
    .platform-name {
        font-size: 14px;
        letter-spacing: 1px;
    }
    .platform-tagline {
        display: none;
    }
    .top-nav-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
    .top-nav-icon {
        font-size: 12px;
    }
    .category-tab {
        padding: 8px 14px;
        font-size: 11px;
    }
    .kg-part-tabs {
        padding: 6px 10px 0;
    }
    .part-tab {
        padding: 10px 12px;
        font-size: 11px;
        gap: 4px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        box-shadow: var(--shadow-lg);
        z-index: 300;
    }
    .sidebar.collapsed {
        margin-left: -300px;
        width: 300px;
        box-shadow: none;
    }
    .top-bar {
        padding: 0 12px;
    }
    .breadcrumb {
        font-size: 12px;
    }
    .top-nav-sep {
        display: none;
    }
    .top-nav-btn {
        padding: 5px 8px;
        font-size: 11px;
    }
    .category-nav {
        overflow-x: auto;
        scrollbar-width: none;
    }
    .category-nav::-webkit-scrollbar {
        display: none;
    }
    .welcome-stats {
        flex-wrap: wrap;
        gap: 12px;
    }
    .welcome-stat {
        min-width: 80px;
        padding: 12px 16px;
    }
}

/* ─── 过渡动画 ──────────────────────────── */

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

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

/* ─── 用户信息栏 ──────────────────────────── */

.user-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: rgba(255,255,255,0.12);
    border-radius: 20px;
    white-space: nowrap;
}

.user-avatar {
    font-size: 16px;
}

.user-name {
    font-size: 13px;
    color: #ffffff;
    font-weight: 600;
}

.user-logout {
    font-size: 11px !important;
    padding: 2px 8px !important;
    color: rgba(255,255,255,0.7) !important;
    background: rgba(255,255,255,0.08) !important;
    border-radius: 10px !important;
}

.user-logout:hover {
    color: #ffffff !important;
    background: rgba(239,68,68,0.6) !important;
}

/* ─── 认证模态框 ──────────────────────────── */

.auth-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.auth-overlay.active {
    display: flex;
}

.auth-modal {
    background: #ffffff;
    border-radius: 16px;
    padding: 36px 40px 30px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    position: relative;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-close {
    position: absolute;
    top: 12px; right: 16px;
    border: none;
    background: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s;
    line-height: 1;
}

.auth-close:hover {
    background: var(--bg);
    color: var(--text);
}

.auth-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 24px;
    text-align: center;
}

.auth-field {
    margin-bottom: 16px;
}

.auth-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.auth-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: all 0.2s;
    outline: none;
}

.auth-field input:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
    background: #ffffff;
}

.auth-field input::placeholder {
    color: var(--text-light);
}

.auth-remember {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 18px;
}

.auth-remember input[type="checkbox"] {
    accent-color: #2563EB;
}

.auth-submit {
    width: 100%;
    padding: 12px;
    background: #2563EB;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 4px;
}

.auth-submit:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 16px rgba(37,99,235,0.3);
}

.auth-submit:active {
    transform: scale(0.98);
}

.auth-switch {
    text-align: center;
    font-size: 13px;
    color: var(--text-light);
    margin-top: 16px;
}

.auth-switch a {
    color: #2563EB;
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-msg {
    margin-top: 12px;
    font-size: 13px;
    text-align: center;
    min-height: 20px;
}

.auth-msg.success {
    color: #16a34a;
}

.auth-msg.error {
    color: #dc2626;
}

/* ─── 历史记录模态框 ───────────────────────── */

.history-modal {
    background: #ffffff;
    border-radius: 16px;
    width: 640px;
    max-width: 92vw;
    max-height: 80vh;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s ease;
    overflow: hidden;
}

.history-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    flex-shrink: 0;
}

.history-tab {
    padding: 14px 24px;
    border: none;
    background: none;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}

.history-tab:hover {
    color: var(--text);
}

.history-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    min-height: 300px;
}

.history-content::-webkit-scrollbar { width: 4px; }
.history-content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.history-list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s;
}

.history-list-item:hover {
    background: var(--sidebar-hover);
}

.history-list-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-lighter);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.history-list-info {
    flex: 1;
    min-width: 0;
}

.history-list-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-list-sub {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

.history-list-time {
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
    flex-shrink: 0;
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-size: 14px;
}

.history-empty-icon {
    font-size: 40px;
    opacity: 0.4;
    margin-bottom: 14px;
}

/* 聊天记录展开 */
.chat-detail {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
}

.chat-detail-q {
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 8px;
}

.chat-detail-a {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}
