/* ==========================================================================
   Wiki 公开知识库前台
   ========================================================================== */
:root {
    --pub-accent: #448AFF;
    --text: #1f2937;
    --text-2: #4b5563;
    --muted: #6b7280;
    --line: #e8eaef;
    --bg: #fff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body.pub-body {
    /* font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif; */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    color: var(--text);
    background: var(--bg);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--pub-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 顶栏 */
.pub-header {
    position: sticky; top: 0; z-index: 40;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
}
.pub-header-inner {
    max-width: none; margin: 0 auto; padding: 0 24px;
    height: 60px; display: flex; align-items: center; gap: 18px;
}
.pub-menu-btn {
    display: none; border: 1px solid var(--line); background: #fff; border-radius: 5px;
    width: 34px; height: 34px; cursor: pointer; font-size: 14px;
}
.pub-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; font-size: 15px; flex: 0 0 auto; }
.pub-brand:hover { text-decoration: none; }
.pub-brand-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pub-search { flex: 1; max-width: 380px; margin-left: auto; }
/* 移动端搜索按钮：桌面端隐藏 */
.pub-search-btn {
    display: none; flex: 0 0 auto; align-items: center; justify-content: center;
    width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 5px;
    background: #fff; color: var(--text-2); cursor: pointer; padding: 0;
}
.pub-search input {
    width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 5px;
    padding: 0 13px; font-size: 13.5px; outline: none; background: #fafbfc; color: var(--text);
    font-family: inherit; transition: all .15s;
}
.pub-search input:focus { border-color: var(--pub-accent); background: #fff; box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
/* 搜索按钮：桌面端隐藏，仅移动端展开时显示 */
.pub-search-submit { display: none; }

.pub-source { font-size: 12px; color: #9aa1ad; flex: 0 0 auto; }
.pub-source:hover { color: var(--text-2); text-decoration: none; }

/* 布局：全屏宽度，目录贴左，正文居中 */
.pub-layout { max-width: none; margin: 0; display: grid; grid-template-columns: 258px minmax(0, 1fr); gap: 0; }
.pub-layout.no-aside { grid-template-columns: 1fr; }

.pub-side {
    border-right: 1px solid var(--line);
    padding: 15px 18px 30px;
    position: sticky; top: 60px;
    height: calc(100vh - 61px);
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, .18) transparent;
}
.pub-side::-webkit-scrollbar { width: 5px; height: 5px; }
.pub-side::-webkit-scrollbar-track { background: transparent; }
.pub-side::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .18); border-radius: 3px; }
.pub-side::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .32); }
.pub-side::-webkit-scrollbar-button { display: none; }
.pub-side-head { font-size: 11.5px; letter-spacing: .8px; text-transform: uppercase; color: #9aa1ad; margin-bottom: 12px; }
.pub-side-empty { font-size: 12.5px; color: var(--muted); }

.pub-tree { list-style: none; margin: 0; padding: 0; }
.pub-tree .pub-tree { padding-left: 12px; margin-top: 2px; }
.pub-tree li { margin: 0; }
.pub-folder { margin-bottom: 2px; }
.pub-folder-details > summary { list-style: none; cursor: pointer; user-select: none; }
.pub-folder-details > summary::-webkit-details-marker { display: none; }
.pub-folder-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: #8b93a1; font-weight: 600;
    padding: 7px 8px 4px; letter-spacing: .2px;
}
.pub-folder-title::before {
    content: ''; flex: 0 0 auto; width: 0; height: 0;
    border-left: 4px solid #9aa1ad;
    border-top: 3.5px solid transparent; border-bottom: 3.5px solid transparent;
    transition: transform .12s;
}
.pub-folder-details[open] > .pub-folder-title::before { transform: rotate(90deg); }
.pub-link {
    display: block;
     padding: 7px 10px; border-radius: 5px;
    font-size: 13.5px; color: var(--text-2); line-height: 1.45;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    /* display: flex;
    flex-direction: column;
    gap:1px; */
}
.pub-link:hover { background: #f5f6f9; text-decoration: none; color: var(--text); }
.pub-link.active { background: color-mix(in srgb, var(--pub-accent) 10%, #fff); color: var(--pub-accent); font-weight: 600; }
/* 多级目录下的 hover / 当前项高亮背景向左对齐，不跟随缩进 */
.pub-tree .pub-tree .pub-link:is(:hover, .active) { margin-left: -12px; padding-left: 22px; }
.pub-tree .pub-tree .pub-tree .pub-link:is(:hover, .active) { margin-left: -24px; padding-left: 34px; }
.pub-tree .pub-tree .pub-tree .pub-tree .pub-link:is(:hover, .active) { margin-left: -36px; padding-left: 46px; }
.pub-tree .pub-tree .pub-tree .pub-tree .pub-tree .pub-link:is(:hover, .active) { margin-left: -48px; padding-left: 58px; }
.pub-tree .pub-tree .pub-tree .pub-tree .pub-tree .pub-tree .pub-link:is(:hover, .active) { margin-left: -60px; padding-left: 70px; }

.pub-main { padding: 44px 48px 0; min-width: 0; }
.pub-doc, .pub-home, .pub-missing, .pub-hero, .pub-empty,
.pub-search-head, .pub-result-list, .pub-pager {
    margin-left: auto; margin-right: auto;
}
.pub-doc { max-width: 800px; }
.pub-doc h1 { font-size: 30px; line-height: 1.35; margin: 0 0 10px; letter-spacing: -.4px; }
.pub-meta { font-size: 12.5px; color: #9aa1ad; margin-bottom: 26px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }

/* 正文排版 */
.pub-content { font-size: 15.5px; color: var(--text-2); word-break: break-word; }
.pub-content > *:first-child { margin-top: 0; }
.pub-content h1, .pub-content h2, .pub-content h3, .pub-content h4 {
    color: var(--text); line-height: 1.4; margin: 30px 0 12px; letter-spacing: -.2px;
}
.pub-content h1 { font-size: 24px; }
.pub-content h2 { font-size: 21px; }
.pub-content h3 { font-size: 18px; }
.pub-content h4 { font-size: 16px; }
.pub-content p { margin: 0 0 14px; }
.pub-content a { border-bottom: 1px solid color-mix(in srgb, var(--pub-accent) 30%, transparent); }
.pub-content a:hover { text-decoration: none; }
.pub-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 8px 0; border: 1px solid var(--line); }
.pub-content ul, .pub-content ol { padding-left: 24px; margin: 0 0 14px; }
.pub-content li { margin-bottom: 6px; }
.pub-content blockquote {
    margin: 16px 0; padding: 10px 18px; border-left: 3px solid var(--pub-accent);
    background: #fafbfc; color: var(--text-2); border-radius: 0 8px 8px 0;
}
.pub-content code {
    background: #f3f4f6; padding: 2px 6px; border-radius: 5px;
    /* font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;  */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 13px;
}
.pub-content pre {
    background: #f8f9fb; border: 1px solid var(--line); border-radius: 10px;
    padding: 14px 16px; overflow: auto; margin: 0 0 16px;
}
.pub-content pre code { background: none; padding: 0; }
.pub-content table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 14px; }
.pub-content th, .pub-content td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.pub-content th { background: #fafbfc; color: var(--text); font-weight: 600; }
.pub-content hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }

/* 代码块语法高亮（与编辑器输出的 token 类名对应） */
.pub-content pre code { color: #24292f; }
.pub-content .token.comment,
.pub-content .token.prolog,
.pub-content .token.doctype,
.pub-content .token.cdata { color: #6a737d; font-style: italic; }
.pub-content .token.punctuation { color: #24292f; }
.pub-content .token.property,
.pub-content .token.tag,
.pub-content .token.constant,
.pub-content .token.symbol,
.pub-content .token.deleted { color: #005cc5; }
.pub-content .token.boolean,
.pub-content .token.number { color: #005cc5; }
.pub-content .token.selector,
.pub-content .token.attr-name,
.pub-content .token.string,
.pub-content .token.char,
.pub-content .token.builtin,
.pub-content .token.inserted { color: #22863a; }
.pub-content .token.operator,
.pub-content .token.entity,
.pub-content .token.url { color: #d73a49; }
.pub-content .token.atrule,
.pub-content .token.attr-value,
.pub-content .token.keyword { color: #d73a49; }
.pub-content .token.function,
.pub-content .token.class-name { color: #6f42c1; }
.pub-content .token.regex,
.pub-content .token.important,
.pub-content .token.variable { color: #e36209; }
.pub-content .token.important,
.pub-content .token.bold { font-weight: 700; }
.pub-content .token.italic { font-style: italic; }
.pub-content .token.entity { cursor: help; }

/* 知识库首页 */
.pub-home { max-width: 800px; padding-top: 10px; }
.pub-home-hero {
    display: flex; align-items: flex-start; gap: 28px;
    padding-bottom: 26px; border-bottom: 1px solid var(--line);
}
.pub-home-cover {
    flex: 0 0 200px; width: 200px; aspect-ratio: 2 / 3;
    border-radius: 12px; overflow: hidden; background: #f3f4f6;
    /* box-shadow: 0 8px 22px rgba(17, 24, 39, .12); */
}
.pub-home-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pub-home-head { flex: 1; min-width: 0; }
.pub-home h1 { font-size: 32px; line-height: 1.3; margin: 0 0 10px; letter-spacing: -.4px; }
.pub-home-desc { margin: 0; color: var(--muted); font-size: 15px; white-space: pre-wrap;word-wrap: break-word;}
.pub-home-start {
    display: inline-flex; align-items: center; justify-content: center;
    height: 38px; padding: 0 22px; margin-top: 18px;
    border-radius: 5px; background: var(--pub-accent); color: #fff;
    font-size: 13.5px; font-weight: 600; transition: opacity .16s;
}
.pub-home-start:hover { color: #fff; text-decoration: none; opacity: .9; }

.pub-home-stats { display: flex; flex-wrap: wrap; gap: 14px; margin: 26px 0 22px; }
.pub-stat {
    flex: 1 1 140px; min-width: 120px; border: 1px solid var(--line); border-radius: 12px;
    padding: 16px 18px; display: flex; flex-direction: column; gap: 3px; background: #fcfcfd;
}
.pub-stat-wide { flex: 1.4 1 200px; }
.pub-stat-num { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.35; }
.pub-stat-label { font-size: 12.5px; color: var(--muted); }
.pub-home-tip { font-size: 13.5px; color: var(--muted); margin: 0; }

/* 首页目录（书本目录样式） */
.pub-home-toc { border-top: 1px solid var(--line); padding-top: 24px; }
.pub-toc-head { font-size: 18px; font-weight: 700; margin: 0 0 12px; letter-spacing: -.2px; }
.pub-toc-list { list-style: none; margin: 0; padding: 0; }
.pub-toc-list .pub-toc-list { position: relative; margin: 2px 0 4px; padding: 0; }
.pub-toc-list .pub-toc-list::before {
    content: ""; position: absolute; top: 4px; bottom: 4px;
    left: calc(13px + (var(--toc-depth) - 1) * 24px);
    border-left: 1px dashed #e5e7eb; z-index: 1; pointer-events: none;
}
.pub-toc-row {
    display: flex; align-items: baseline; gap: 10px;
    padding: 7px 10px; padding-left: calc(10px + var(--toc-depth) * 24px);
    border-radius: 6px; transition: background .16s;
}
.pub-toc-row:hover { background: #fafbfc; }
.pub-toc-num {
    flex: 0 0 auto; min-width: 28px; color: #9aa1ad; font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}
.pub-toc-title {
    font-size: 14px; color: var(--text); min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.pub-toc-title:hover { color: var(--pub-accent); text-decoration: none; }
.pub-toc-folder { font-weight: 600; }

/* 文档缺失 */
.pub-missing { max-width: 800px; padding-top: 40px; text-align: center; }
.pub-missing-icon { font-size: 38px; margin-bottom: 12px; }
.pub-missing h1 { font-size: 24px; margin: 0 0 12px; }
.pub-missing p { color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.pub-missing-tip { font-size: 13px; color: #9aa1ad; }

/* 上下篇 */
.pub-pager {
    max-width: 800px; display: flex; justify-content: space-between; gap: 16px;
    margin-top: 46px; padding-top: 22px; 
    /* border-top: 1px solid var(--line); */
}
.pub-pager-item {
    flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 13px 16px;
    border: 1px solid var(--line); border-radius: 10px; color: var(--text);
    transition: all .16s; max-width: 48%;
}
.pub-pager-item:hover { border-color: var(--pub-accent); text-decoration: none; background: #fcfcff; }
.pub-pager-item.next { margin-left: auto; text-align: right; }
.pub-pager-label { font-size: 11.5px; color: #9aa1ad; }
.pub-pager-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 首页 / 空态 */
.pub-hero { max-width: 800px; padding-bottom: 26px; border-bottom: 1px solid var(--line); margin-bottom: 30px; }
.pub-hero h1 { font-size: 30px; margin: 0 0 8px; }
.pub-hero p { margin: 0; color: var(--muted); font-size: 15px; }
.pub-empty { max-width: 800px; padding: 40px 0; color: var(--muted); font-size: 14px; }

/* 搜索页 */
.pub-search-head { max-width: 800px; }
.pub-search-head h1 { font-size: 26px; margin: 0 0 16px; }
.pub-search-form { display: flex; gap: 8px; margin-bottom: 14px; }
.pub-search-form input {
    flex: 1; height: 40px; border: 1px solid var(--line); border-radius: 5px;
    padding: 0 13px; font-size: 14px; outline: none; font-family: inherit;
}
.pub-search-form input:focus { border-color: var(--pub-accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.pub-search-form button {
    height: 40px; padding: 0 20px; border: 0; border-radius: 5px;
    background: var(--pub-accent); color: #fff; font-size: 13.5px; font-weight: 600;
    cursor: pointer; font-family: inherit;
}
.pub-search-tip { font-size: 13px; color: var(--muted); margin: 0 0 18px; }

.pub-result-list { list-style: none; margin: auto; padding: 0; max-width: 800px; }
.pub-result-list li { margin-bottom: 4px; }
.pub-result {
    display: block; padding: 14px 16px; border-radius: 10px;
    border: 1px solid transparent; color: var(--text);
}
.pub-result:hover { background: #fafbfc; border-color: var(--line); text-decoration: none; }
.pub-result-title { display: block; font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.pub-result-desc { display: block; font-size: 13px; color: var(--muted); line-height: 1.6; }

/* 页脚 */
.pub-footer {
    max-width: 800px;
    border-top: 1px solid var(--line);
    padding: 22px 24px; display: flex; justify-content: center; gap: 14px;
    font-size: 12px; color: #9aa1ad;
    margin: 46px auto 0;
}
.pub-footer a{
    color: #9aa1ad;
}

/* 响应式 */
@media (max-width: 980px) {
    .pub-main { padding: 44px 26px 0; }
}

@media (max-width: 820px) {
    .pub-pager ,.pub-footer{margin-top: 30px;}
    .pub-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
    .pub-layout { grid-template-columns: 1fr; }
    .pub-side {
        position: fixed; top: 60px; left: 0; bottom: 0; width: 272px; z-index: 45;
        background: #fff; border-right: 1px solid var(--line); height: auto;
        transform: translateX(-100%); transition: transform .2s; 
        /* box-shadow: 0 12px 30px rgba(17,24,39,.12); */
    }
    .pub-side.open { transform: translateX(0); }
    .pub-source { display: none; }
    .pub-doc h1 { font-size: 24px; }
}

@media (max-width: 560px) {
    .pub-main { padding: 24px 16px 0; }
    .pub-header-inner { padding: 0 12px; gap: 10px; }
    .pub-side{width:100%}
    /* 小屏幕：搜索框收进图标，展开后显示在标题栏下方 */
    .pub-search-btn { display: inline-flex; margin-left: auto; }
    /* .pub-search-btn[aria-expanded="true"] { border-color: var(--pub-accent); color: var(--pub-accent); } */
    .pub-search { display: none; }
    .pub-header.search-open .pub-search {
        display: flex; gap: 8px; position: absolute; left: 0; right: 0; top: 100%;
        max-width: none; margin: 0; padding: 10px 12px 12px;
        background: #fff; border-bottom: 1px solid var(--line);
        box-shadow: 0 10px 20px rgba(17, 24, 39, .08); z-index: 40;
    }
    .pub-header.search-open .pub-search input { flex: 1 1 auto; width: auto; }
    .pub-header.search-open .pub-search-submit {
        display: inline-flex; align-items: center; justify-content: center;
        flex: 0 0 auto; height: 36px; padding: 0 16px; border: 0; border-radius:5px;
        background: var(--pub-accent); color: #fff; font-size: 13.5px;
        font-family: inherit; cursor: pointer;
    }
    /* 搜索框收进图标后，标题自适应剩余宽度并在超出时省略 */
    .pub-brand { flex: 1 1 auto; min-width: 0; }
    .pub-brand-name { max-width: none; min-width: 0; }
    .pub-content { font-size: 15px; }
    .pub-pager { flex-direction: column; }
    .pub-pager-item { max-width: none; }
    .pub-pager-item.next{text-align: left;margin-left: 0}
    .pub-home-hero { gap: 16px; }
    .pub-home-cover { flex-basis: 132px; width: 132px; }
    .pub-home h1 { font-size: 24px; }
}
