* { box-sizing: border-box; }
:root {
    color-scheme: light;
    --bg: #fff;
    --bg-soft: #fafafa;
    --bg-hover: #f0f5ff;
    --bg-active: #e6f4ff;
    --bg-muted: #f5f6f7;
    --text: #1f2329;
    --text-secondary: #595959;
    --text-muted: #8c8c8c;
    --link: #1677ff;
    --border: #e8e8e8;
    --border-soft: #f0f0f0;
    --input-border: #d9d9d9;
    --star: #d48806;
    --star-bg: #fffbe6;
}
html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #14181d;
    --bg-soft: #1c2128;
    --bg-hover: #243044;
    --bg-active: #1a3352;
    --bg-muted: #2a3038;
    --text: #e8eaed;
    --text-secondary: #c4c7cc;
    --text-muted: #9aa0a6;
    --link: #6cb6ff;
    --border: #2e343c;
    --border-soft: #2a3038;
    --input-border: #3a414a;
    --star: #f0c14b;
    --star-bg: #3a3018;
}
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--link); text-decoration: none; }
.topbar {
    height: 56px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg);
    z-index: 5;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 650;
    color: var(--text);
    white-space: nowrap;
}
.brand img { width: 32px; height: 32px; border-radius: 50%; display: block; }
.search { flex: 1; max-width: 420px; }
.search input {
    width: 100%;
    height: 34px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    padding: 0 12px;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}
.theme-toggle {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-muted); }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
.layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.side {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-soft);
    padding: 16px 12px 32px;
    background: var(--bg-soft);
    overflow: auto;
    height: 100%;
    z-index: 4;
}
.side a, .side button { position: relative; z-index: 1; pointer-events: auto; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-muted); margin: 0 8px 10px; }
.side-head:has(.side-toggle) {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 0 10px;
    padding: 16px 8px 8px;
    background: var(--bg-soft);
}
.side-head-tools { display: inline-flex; align-items: center; gap: 2px; }
.side-toggle, .side-show {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.side-toggle:hover, .side-show:hover { background: var(--bg-muted); color: var(--text); }
.stage { position: relative; }
.side-show {
    display: none;
    position: fixed;
    left: 12px;
    top: 68px;
    z-index: 30;
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
body.side-hidden .side { display: none; }
body.side-hidden .side-show { display: inline-flex; }
.fav-block { margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border-soft); }
.tree-node { margin: 0 0 4px; }
.tree-row { display: flex; align-items: flex-start; }
.tree-toggle {
    width: 22px;
    height: 32px;
    flex-shrink: 0;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    padding: 0;
}
.tree-toggle:hover { background: var(--bg-muted); }
.tree-toggle::before {
    content: "";
    display: inline-block;
    border: solid currentColor;
    border-width: 0 1.5px 1.5px 0;
    padding: 3px;
    transform: rotate(45deg);
    margin-top: -4px;
}
.tree-node.collapsed > .tree-row .tree-toggle::before { transform: rotate(-45deg); margin-top: 0; }
.tree-node.collapsed > .tree-children { display: none; }
.tree-toggle.spacer { cursor: default; }
.tree-toggle.spacer::before { display: none; }
.tree-toggle.spacer:hover { background: transparent; }
.tree-cat, .doc-link {
    display: block;
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    margin: 1px 0;
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    cursor: pointer;
}
.tree-cat { font-weight: 650; }
.tree-children { margin-left: 14px; }
.tree-cat:hover, .doc-link:hover { background: var(--bg-hover); }
.tree-cat.active, .doc-link.active { background: var(--bg-active); color: var(--link); }
.stage { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.stage-bar {
    flex-shrink: 0;
    z-index: 3;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 8px 0 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border-soft);
}
.stage-body { display: flex; align-items: flex-start; flex: 1; min-width: 0; min-height: 0; overflow: auto; }
.main { flex: 1; min-width: 0; padding: 28px 40px 80px 48px; }
.reader { max-width: 800px; }
.doc-actions { display: flex; gap: 4px; flex-shrink: 0; }
.icon-btn {
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.icon-btn:hover { background: var(--bg-muted); }
.icon-btn.active { color: var(--star); background: var(--star-bg); border-color: var(--star); }
.icon-btn.active svg path { fill: currentColor; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.cat-group { margin-top: 40px; }
.cat-group-title { font-size: 22px; margin: 0 0 8px; color: var(--text); }
.cat-section + .cat-section { margin-top: 36px; padding-top: 28px; border-top: 1px solid var(--border-soft); }
.doc .cat-section > h2,
.doc .cat-section > h3 { margin-top: 0; }
.doc .cat-section > h2 a,
.doc .cat-section > h3 a { color: var(--text); }
.cat-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.cat-doc {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    color: var(--text);
}
.cat-doc:hover { border-color: var(--link); background: var(--bg-hover); }
.cat-doc-title { font-weight: 650; }
.cat-doc-sum { color: var(--text-muted); font-size: 13px; }
.cat-child { margin-top: 18px; }
.cat-child-name { font-weight: 650; color: var(--text); }
.cat-child .cat-doc, .cat-child .cat-child { margin-top: 8px; }
.crumb { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
h1 { font-size: 30px; line-height: 1.35; margin: 0 0 12px; font-weight: 650; }
.lead { color: var(--text-secondary); font-size: 15px; line-height: 1.7; margin: 0 0 8px; }
.meta { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.muted { color: var(--text-muted); font-size: 13px; line-height: 1.7; padding: 0 8px; }
.doc { font-size: 15px; line-height: 1.8; }
.doc h1, .doc h2, .doc h3, .doc h4 { scroll-margin-top: 16px; }
.doc h2 { font-size: 22px; margin: 28px 0 10px; }
.doc h3 { font-size: 18px; margin: 22px 0 8px; }
.doc p { margin: 0 0 12px; }
.doc img { max-width: 100%; height: auto; border-radius: 6px; }
.doc ul, .doc ol { margin: 8px 0 12px 1.4em; padding: 0; }
.doc blockquote { margin: 12px 0; padding: 4px 12px; border-left: 3px solid var(--input-border); color: var(--text-secondary); }
.doc a { text-decoration: underline; }
.doc table, .present-body table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.doc th, .doc td, .present-body th, .present-body td { border: 1px solid var(--input-border); padding: 6px 10px; vertical-align: top; }
.doc pre, .present-body pre { margin: 12px 0; padding: 10px 12px; overflow: auto; white-space: pre-wrap; background: var(--bg-hover); border-radius: 6px; }
.doc code, .present-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.pager {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 36px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
    font-size: 14px;
}
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(8px);
    background: var(--text);
    color: var(--bg);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: .2s ease;
    z-index: 90;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
body.presenting { overflow: hidden; }
.present {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: #14181d;
    color: #fff;
    display: flex;
    flex-direction: column;
}
.present-top, .present-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
}
.present-brand { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 14px; }
.present-brand img { width: 24px; height: 24px; border-radius: 50%; }
.present-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6vw 12px;
}
.present-card {
    width: min(920px, 100%);
    max-height: 100%;
    overflow: auto;
    background: var(--bg);
    color: var(--text);
    border-radius: 16px;
    padding: 42px 48px;
}
.present-card h2 { font-size: 34px; line-height: 1.35; margin: 0 0 18px; }
.present-body { font-size: 18px; line-height: 1.75; }
.present-body img { max-width: 100%; height: auto; border-radius: 8px; }
.present-bar { justify-content: center; }
.present-bar button, .present-close {
    height: 34px;
    border: 1px solid rgba(255,255,255,.25);
    background: transparent;
    color: #fff;
    border-radius: 8px;
    padding: 0 14px;
    cursor: pointer;
}
.present-bar button:disabled { opacity: .35; cursor: default; }
.present-index { min-width: 64px; text-align: center; font-size: 14px; }
@media (max-width: 860px) {
    html, body { height: auto; min-height: 100%; overflow: auto; }
    body { display: block; }
    .layout { display: block; overflow: visible; }
    .side { width: auto; height: auto; max-height: 46vh; border-right: none; border-bottom: 1px solid var(--border-soft); }
    .stage, .stage-body { overflow: visible; height: auto; }
    .main { padding: 20px 16px 48px; }
    .present-card { padding: 24px 18px; }
    .present-card h2 { font-size: 26px; }
}
