/* ═══════════ 主导航 ═══════════ */
.main-nav {
    display: flex;
    gap: 4px;
    padding: 8px 24px 0;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}
.main-nav-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 15px;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-family: inherit;
}
.main-nav-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 600;
}

/* ═══════════ 知识库布局 ═══════════ */
#knowledgePanel {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px 60px;
}

.kb-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.kb-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    flex: 1;
    min-width: 240px;
}
.kb-search input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 14px;
    background: transparent;
}
.kb-view-switch {
    display: flex;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}
.kb-view-btn {
    padding: 6px 14px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
    font-family: inherit;
}
.kb-view-btn.active {
    background: #fff;
    color: #2563eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-weight: 600;
}

.kb-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
}

/* ═══════════ 左栏 ═══════════ */
.kb-sidebar {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    height: fit-content;
    position: sticky;
    top: 80px;
    border: 1px solid #e5e7eb;
}
.kb-side-block { margin-bottom: 20px; }
.kb-side-title {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.kb-mini-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #2563eb;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
}
.kb-mini-btn:hover { background: #eff6ff; }

.kb-cat-list { display: flex; flex-direction: column; gap: 2px; }
.kb-cat {
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    color: #374151;
}
.kb-cat:hover { background: #f3f4f6; }
.kb-cat.active { background: #eff6ff; color: #2563eb; font-weight: 500; }
.kb-cat-count { color: #9ca3af; font-size: 12px; }

.kb-tag-dim { margin-bottom: 12px; }
.kb-tag-dim-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
}
.kb-tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.kb-tag {
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    transition: 0.15s;
}
.kb-tag:hover { transform: translateY(-1px); }
.kb-tag.active { font-weight: 500; }

/* ═══════════ 主区 ═══════════ */
.kb-main { min-height: 400px; }

.kb-card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.kb-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 18px;
    cursor: pointer;
    transition: 0.2s;
}
.kb-card:hover {
    border-color: #93c5fd;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37,99,235,0.08);
}
.kb-card-q {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}
.kb-card-a {
    font-size: 14px;
    color: #475569;
    margin-bottom: 10px;
    line-height: 1.6;
}
.kb-card-meta {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: #9ca3af;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.kb-cat-badge {
    background: #dbeafe;
    color: #1e40af;
    padding: 1px 8px;
    border-radius: 8px;
    font-size: 11px;
}
.kb-card-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.kb-tag-mini {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ═══════════ 时间轴 ═══════════ */
.kb-timeline { padding: 20px 0; }
.kb-tl-year {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
.kb-tl-year-label {
    font-size: 24px;
    font-weight: bold;
    color: #2563eb;
    padding-top: 4px;
}
.kb-tl-items { display: flex; flex-direction: column; gap: 10px; }
.kb-tl-item {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    transition: 0.2s;
}
.kb-tl-item:hover { border-color: #93c5fd; background: #f8fafc; }
.kb-tl-item-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: #2563eb;
    flex-shrink: 0;
    margin-top: 6px;
}
.kb-tl-item-q { font-size: 14px; font-weight: 500; color: #1e293b; }
.kb-tl-item-label { font-size: 12px; color: #6b7280; margin-top: 4px; }

/* ═══════════ 图谱 ═══════════ */
.kb-graph {
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    min-height: 620px;
    border: 1px solid #e5e7eb;
}

/* ═══════════ 卡片编辑器抽屉 ═══════════ */
.card-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.5);
    z-index: 2000;
    display: flex;
    justify-content: flex-end;
}
.card-editor {
    width: 100%;
    max-width: 680px;
    background: #fff;
    display: flex;
    flex-direction: column;
    height: 100%;
    animation: slideIn 0.25s ease;
}
@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
.card-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}
.card-editor-header h3 { margin: 0; font-size: 18px; }
.card-editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}
.card-editor-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.tag-picker {
    background: #f9fafb;
    border-radius: 8px;
    padding: 10px;
}
.cd-tag-dim {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}
.cd-tag-dim-name {
    font-size: 12px;
    font-weight: 600;
    width: 50px;
    flex-shrink: 0;
}
.cd-tag {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    transition: 0.15s;
}
.cd-tag:hover { transform: translateY(-1px); }

.cd-file-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.cd-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 6px;
    font-size: 13px;
}

/* ═══════════ 文件选择器 ═══════════ */
.file-picker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.file-picker-item:hover { background: #f3f4f6; }
.file-picker-item.picked { opacity: 0.4; }

@media (max-width: 900px) {
    .kb-layout { grid-template-columns: 1fr; }
    .kb-sidebar { position: static; }
    .card-editor { max-width: 100%; }
    .form-row { grid-template-columns: 1fr; }
}