/* 知识体系 · 详情页（左知识树 + 右知识点题目；科技简约风，仅用设计令牌） */

.ks-show {
    min-height: 70vh;
    padding: 32px 24px 56px;
    box-sizing: border-box;
    color: var(--tech-text);
    /* 科技背景与 Element Plus 主色由 .ds-app 提供 */
}

.ks-show *,
.ks-show *::before,
.ks-show *::after {
    box-sizing: border-box;
}

.ks-show [v-cloak] {
    display: none;
}

/* ===== 面包屑 ===== */
.ks-crumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    font-size: var(--font-sm);
}

.ks-crumb-link {
    color: var(--tech-text-2);
    text-decoration: none;
    transition: color var(--dur-fast) var(--ease);
}

.ks-crumb-link:hover {
    color: var(--tech-accent-strong);
}

.ks-crumb-sep {
    color: var(--tech-text-3);
}

.ks-crumb-current {
    color: var(--tech-text);
}

/* ===== 体系头部 ===== */
.ks-head {
    margin-bottom: var(--space-5);
    padding: 22px 24px;
    background: var(--tech-panel);
    border: 1px solid var(--tech-line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.ks-head::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--tech-grad-line);
}

.ks-head-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.ks-head-title {
    margin: 0;
    font-size: var(--font-3xl);
    font-weight: 700;
    letter-spacing: .2px;
    color: var(--tech-text);
}

.ks-level {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    color: #fff;
    background: var(--tech-vip-grad);
    box-shadow: var(--shadow-xs);
}

.ks-head-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.ks-head-stat {
    font-size: var(--font-xs);
    color: var(--tech-text-2);
    background: var(--tech-panel-2);
    border: 1px solid var(--tech-line);
    border-radius: var(--radius-pill);
    padding: 4px 12px;
}

.ks-head-stat b {
    font-weight: 700;
    color: var(--tech-accent-strong);
    font-variant-numeric: tabular-nums;
}

.ks-head-desc {
    margin: var(--space-3) 0 0;
    font-size: var(--font-sm);
    line-height: 1.7;
    color: var(--tech-text-2);
}

/* ===== 双栏骨架 ===== */
.ks-layout {
    display: grid;
    grid-template-columns: 288px minmax(0, 1fr);
    gap: var(--space-6);
    align-items: start;
}

/* 移动端“展开知识树”按钮：桌面隐藏 */
.ks-tree-toggle {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--tech-text);
    background: var(--tech-panel);
    border: 1px solid var(--tech-line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.ks-tree-toggle-arrow {
    color: var(--tech-text-2);
    transition: transform var(--dur-fast) var(--ease);
}

.ks-tree-toggle-arrow.is-open {
    transform: rotate(180deg);
}

.ks-tree-mask {
    display: none;
}

/* ===== 左侧知识树 ===== */
.ks-tree {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    background: var(--tech-panel);
    border: 1px solid var(--tech-line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 16px;
    overflow: hidden;
}

.ks-tree-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 14px 16px;
    border-bottom: 1px solid var(--tech-line);
}

.ks-tree-title {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--tech-text);
}

.ks-tree-total {
    flex-shrink: 0;
    font-size: var(--font-xs);
    color: var(--tech-accent-strong);
    background: var(--tech-accent-soft);
    border: 1px solid var(--tech-accent-line);
    border-radius: var(--radius-pill);
    padding: 3px 10px;
    white-space: nowrap;
}

.ks-tree-search {
    padding: var(--space-3) var(--space-4) var(--space-2);
}

.ks-tree-input {
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: var(--font-sm);
    color: var(--tech-text);
    background: var(--tech-panel-2);
    border: 1px solid var(--tech-line);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.ks-tree-input::placeholder {
    color: var(--tech-text-3);
}

.ks-tree-input:focus {
    border-color: var(--tech-accent-line);
    box-shadow: 0 0 0 3px var(--tech-accent-soft);
}

.ks-tree-body {
    flex: 1;
    min-height: 0;
    padding: var(--space-2) var(--space-3) var(--space-4);
    overflow-y: auto;
}

.ks-tree-list,
.ks-tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ks-tree-children {
    padding-left: 14px;
}

.ks-tree-row {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: 8px 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease),
        border-color var(--dur-fast) var(--ease),
        color var(--dur-fast) var(--ease);
}

.ks-tree-row:hover {
    background: var(--tech-panel-2);
}

.ks-tree-row.is-active {
    background: var(--tech-accent-soft);
    border-color: var(--tech-accent-line);
}

.ks-tree-row.is-active .ks-tree-name {
    color: var(--tech-accent-strong);
    font-weight: 700;
}

.ks-tree-caret {
    appearance: none;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    font-size: 10px;
    line-height: 1;
    color: var(--tech-text-3);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.ks-tree-caret:hover {
    color: var(--tech-accent-strong);
}

.ks-tree-caret.is-open {
    transform: rotate(90deg);
}

.ks-tree-dot {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    color: var(--tech-text-3);
}

.ks-tree-dot::before {
    content: '\00b7';
}

.ks-tree-name {
    flex: 1;
    min-width: 0;
    font-size: var(--font-sm);
    color: var(--tech-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ks-tree-count {
    flex-shrink: 0;
    font-size: 11px;
    line-height: 1.6;
    color: var(--tech-text-2);
    background: var(--tech-panel-2);
    border: 1px solid var(--tech-line);
    border-radius: var(--radius-pill);
    padding: 0 7px;
    font-variant-numeric: tabular-nums;
}

.ks-tree-empty {
    padding: 28px 0;
    text-align: center;
    font-size: var(--font-sm);
    color: var(--tech-text-2);
}

/* ===== 右侧主栏 ===== */
.ks-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.ks-point {
    padding: 18px 20px;
    background: var(--tech-panel);
    border: 1px solid var(--tech-line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.ks-point-path {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: var(--space-2);
    font-size: var(--font-xs);
    color: var(--tech-text-2);
}

.ks-point-path-sep {
    color: var(--tech-text-3);
}

.ks-point-path-current {
    color: var(--tech-accent-strong);
    font-weight: 600;
}

.ks-point-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
}

.ks-point-title {
    margin: 0;
    font-size: var(--font-xl);
    font-weight: 700;
    color: var(--tech-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ks-point-total {
    flex-shrink: 0;
    font-size: var(--font-sm);
    color: var(--tech-text-2);
}

.ks-point-desc {
    margin: var(--space-2) 0 0;
    font-size: var(--font-sm);
    line-height: 1.7;
    color: var(--tech-text-2);
}

/* ===== 题目列表 ===== */
.ks-list {
    position: relative;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.ks-loading {
    position: absolute;
    inset: 0;
    z-index: var(--z-loading);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: var(--font-sm);
    color: var(--tech-text-2);
    background: var(--tech-panel-2);
    border-radius: var(--radius-lg);
}

.ks-loading-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid var(--tech-accent-soft);
    border-top-color: var(--tech-accent);
    border-radius: var(--radius-circle);
    animation: ks-spin .8s linear infinite;
}

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

.ks-q {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
    padding: 12px 16px;
    background: var(--tech-panel);
    border: 1px solid var(--tech-line);
    border-radius: var(--radius-md);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.ks-q:hover {
    border-color: var(--tech-accent-line);
    box-shadow: var(--shadow-sm);
}

.ks-q-no {
    font-size: var(--font-xs);
    font-weight: 700;
    color: var(--tech-text-2);
    font-family: var(--font-mono);
}

.ks-q-title {
    min-width: 0;
    font-size: var(--font-md);
    font-weight: 600;
    line-height: 1.55;
    color: var(--tech-text);
    text-decoration: none;
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    transition: color var(--dur-fast) var(--ease);
}

.ks-q-title:hover {
    color: var(--tech-accent-strong);
}

.ks-q-acc {
    flex-shrink: 0;
    font-size: var(--font-xs);
    font-weight: 600;
    color: var(--tech-success);
    background: var(--tech-success-soft);
    border: 1px solid var(--tech-success-soft);
    border-radius: var(--radius-pill);
    padding: 3px 10px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ks-empty {
    padding: 48px 0;
    text-align: center;
    background: var(--tech-panel);
    border: 1px solid var(--tech-line);
    border-radius: var(--radius-lg);
}

.ks-empty-icon {
    font-size: 36px;
    line-height: 1;
    color: var(--tech-text-3);
    margin-bottom: var(--space-3);
}

.ks-empty-text {
    font-size: var(--font-lg);
    font-weight: 600;
    color: var(--tech-text);
}

.ks-empty-tip {
    margin-top: 6px;
    font-size: var(--font-sm);
    color: var(--tech-text-2);
}

.ks-pager {
    display: flex;
    justify-content: center;
    margin-top: var(--space-2);
}

/* ===== 响应式（1024 / 768） ===== */
@media (max-width: 1024px) {
    .ks-show {
        padding: 24px 24px 44px;
    }

    .ks-layout {
        grid-template-columns: 240px minmax(0, 1fr);
        gap: 18px;
    }

    .ks-head {
        padding: 18px 20px;
    }

    .ks-head-title {
        font-size: var(--font-2xl);
    }
}

@media (max-width: 768px) {
    .ks-show {
        padding: 16px 14px 40px;
    }

    .ks-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .ks-tree-toggle {
        display: flex;
    }

    /* 知识树折叠为覆盖层 */
    .ks-tree {
        position: fixed;
        inset: 0;
        z-index: var(--z-overlay);
        max-height: none;
        border: none;
        border-radius: 0;
        transform: translateY(100%);
        transition: transform var(--dur-base) var(--ease);
    }

    .ks-tree.is-open {
        transform: none;
    }

    .ks-tree-mask {
        display: block;
        position: fixed;
        inset: 0;
        z-index: calc(var(--z-overlay) - 1);
        background: var(--tech-text);
        opacity: .45;
    }

    .ks-tree-body {
        overflow-y: auto;
        padding-bottom: var(--space-8);
    }

    .ks-head {
        padding: 16px 16px;
    }

    .ks-head-title {
        font-size: var(--font-xl);
    }

    .ks-point {
        padding: var(--space-3) var(--space-4);
    }

    .ks-q {
        grid-template-columns: auto auto minmax(0, 1fr);
        row-gap: 6px;
        padding: 10px 12px;
    }

    .ks-q-acc {
        grid-column: 1 / -1;
        justify-self: start;
    }
}
