/* ============================================================
   卷博书房 · 共享骨架（前台/后台通用）
   顶栏 + 左侧目录 + 内容区 + 页脚
   ============================================================ */

:root {
    --bg: #eef1f4;
    --sidebar-bg: #f7f8fa;
    --content-bg: #ffffff;
    --border: #e2e5e9;
    --border-strong: #d0d4da;
    --text: #1f2328;
    --text-secondary: #57606a;
    --text-muted: #8b949e;
    --accent: #3b6ea5;
    --accent-soft: #eef3f8;
    --radius: 6px;
    --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.06);
    --shadow-md: 0 4px 14px rgba(31, 35, 40, 0.10);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
            "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --sidebar-w: 280px;
    --bar-h: 50px;
}

html, body { margin: 0; height: 100%; }

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.app-bar {
    height: var(--bar-h);
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: linear-gradient(#ffffff, #f4f6f8);
    border-bottom: 1px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 10;
}

.app-bar-title { display: flex; align-items: center; flex: none; gap: 9px; font-weight: 600; font-size: 14px; letter-spacing: 0.3px; }
.app-bar-logo { width: 20px; height: 20px; border-radius: 4px; background: url('../favicon.svg') no-repeat center / contain; }
.app-bar-actions { display: flex; flex: none; gap: 4px; }

.bar-btn {
    width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; border-radius: var(--radius); background: transparent;
    color: var(--text-secondary); cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.bar-btn svg { width: 18px; height: 18px; fill: currentColor; }
.bar-btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--border); color: var(--accent); }
.bar-btn:disabled { color: #c3c8cf; cursor: default; }

/* ---------- 布局：左目录 + 右内容 ---------- */
.layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--sidebar-bg); border-right: 1px solid var(--border-strong);
    display: flex; flex-direction: column;
}

.sidebar-search {
    display: flex; align-items: center; gap: 6px; margin: 10px 10px 6px; padding: 6px 9px;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.sidebar-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 110, 165, 0.12); }
.sidebar-search input { border: none; outline: none; flex: 1; font-size: 13px; color: var(--text); background: transparent; min-width: 0; padding: 0; }
.search-icon { width: 15px; height: 15px; fill: var(--text-muted); flex: none; }

.tree { flex: 1; overflow-y: auto; padding: 6px 8px 12px; }
.tree-node { user-select: none; }

.tree-row {
    display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: var(--radius);
    color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background 0.12s, color 0.12s; text-decoration: none;
}
.tree-row:hover { background: #eef1f5; }
.tree-row.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.tree-row .caret { width: 14px; height: 14px; flex: none; fill: var(--text-muted); transition: transform 0.15s; }
.tree-row.folder .caret { transform: rotate(0deg); }
.tree-row.folder.open .caret { transform: rotate(90deg); }
.tree-row.leaf .caret { visibility: hidden; }
.tree-row.nav-leaf .caret { visibility: visible; }
.tree-row.nav-leaf.active .caret { transform: rotate(90deg); }

.tree-row .node-icon { width: 15px; height: 15px; flex: none; fill: var(--text-muted); }
.tree-row.folder > .node-icon { fill: #c9a227; }
.tree-row.leaf > .node-icon { fill: #8b949e; }

.tree-row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.tree-row .badge { flex: none; font-size: 10.5px; color: var(--text-muted); background: #eceff2; border-radius: 9px; padding: 0 7px; line-height: 17px; }
.tree-children { margin-left: 17px; border-left: 1px solid var(--border); padding-left: 6px; }
.tree-children.collapsed { display: none; }
.tree-empty { padding: 14px 10px; color: var(--text-muted); font-size: 13px; text-align: center; }

/* ---------- 页脚 ---------- */
.site-footer {
    flex: none; display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
    gap: 8px 18px; padding: 10px 16px; border-top: 1px solid var(--border-strong);
    background: var(--sidebar-bg); color: var(--text-muted); font-size: 12px;
}
.site-footer a { color: var(--text-secondary); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: none; }

/* ---------- 右侧内容区 ---------- */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.content-scroll { flex: 1; overflow-y: auto; padding: 24px 28px 40px; }

.page {
    max-width: 820px; margin: 0 auto; background: var(--content-bg);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 32px 38px 40px;
}
.page h1 { margin: 0 0 4px; font-size: 24px; line-height: 1.3; letter-spacing: 0.3px; }
.page h2 { font-size: 18px; margin: 28px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.page h3 { font-size: 15.5px; margin: 20px 0 8px; }
.page p { margin: 0 0 14px; }
.page ul, .page ol { margin: 0 0 14px; padding-left: 22px; }
.page li { margin: 4px 0; }
.page a:not(.download-btn) { color: var(--accent); text-decoration: none; }
.page code { font-family: var(--mono); font-size: 12.5px; background: #f3f5f7; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.page pre { background: #f6f8fa; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.page pre code { background: none; border: none; padding: 0; }
.page table { border-collapse: collapse; width: 100%; }
.page th, .page td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }

.page-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 22px; padding-bottom: 16px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 12.5px; }
.page-meta .chip { display: inline-flex; align-items: center; gap: 5px; }

/* 上一篇/下一篇 */
.page-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--border); }
.nav-link { flex: 1; display: block; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-secondary); text-decoration: none; transition: border-color 0.15s, color 0.15s, background 0.15s; }
.nav-link:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.nav-link.prev { text-align: left; }
.nav-link.next { text-align: right; }
.nav-link span { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }

/* 分页 */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 18px; font-size: 13px; }
.pagination a, .pagination span { padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text-secondary); }
.pagination a:hover, .pagination a.active { border-color: var(--accent); color: var(--accent); }
