/* ============================================================
   CUAV 文档中心 - 新风格覆盖样式
   基于 cule-style.css 适配 GitBook 3 DOM 结构：
   - 隐藏旧 Bootstrap navbar / GitBook book-header
   - 新 .cuav-header（深色玻璃风格）
   - .book-summary 卡片化侧边目录
   - .page-inner / .markdown-section 卡片化正文
   - .cuav-page-toc 右侧固定大纲
   - html[data-theme='dark'] 昼夜切换
   ============================================================ */

:root{
  --bg:#f4f6fb; --card:#ffffff; --text:#1f2937; --muted:#6b7280;
  --accent:#2563eb; --accent-soft:#eff6ff; --border:#e5e7eb;
  --code-bg:#f6f8fa; --code-border:#e5e7eb;
  --maxw:920px;
}

*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:"PingFang SC","Microsoft YaHei","Hiragino Sans GB","Source Han Sans SC","Noto Sans CJK SC",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  font-size:16px; line-height:1.85; -webkit-font-smoothing:antialiased;
}

/* 隐藏旧版顶栏 */
.navbar.fixed-top,
.book-header{
  display:none !important;
}

/* =========================================================
   1. 新顶栏 .cuav-header（深色 Navy）
   ========================================================= */
.cuav-header{
  position:fixed; top:0; left:0; right:0; z-index:1000;
  height:49px; background:#0f172a; border-bottom:1px solid #1e293b;
  font-family:inherit; font-size:15px; color:#e2e8f0;
}
.cuav-header-inner{
  max-width:1400px; height:100%; margin:0 auto; padding:0 16px 0 6px;
  display:flex; align-items:center; gap:16px;
}
.cuav-logo{
  display:flex; align-items:center; gap:9px; text-decoration:none;
  color:#e2e8f0; flex-shrink:0; margin-right:auto;
}
.cuav-logo-img{
  height:28px; width:auto; display:block;
}
.cuav-logo-sub{
  font-size:13px; font-weight:500; color:#cbd5e1; white-space:nowrap;
  padding-left:9px; border-left:1px solid rgba(203,213,225,.35);
}
.cuav-nav{
  display:flex; align-items:center; gap:6px; flex-wrap:nowrap; overflow:visible;
}
.cuav-nav-item{position:relative;}
.cuav-nav-title{
  display:flex; align-items:center; gap:5px; padding:7px 10px; border:0;
  background:transparent; color:inherit; font-size:14px; font-weight:500;
  cursor:pointer; border-radius:6px; white-space:nowrap; font-family:inherit;
}
.cuav-nav-title:hover{background:rgba(255,255,255,.1);}
.cuav-nav-title .arrow{
  display:inline-block; width:0; height:0; margin-top:2px;
  border-left:4px solid transparent; border-right:4px solid transparent;
  border-top:4px solid #94a3b8;
}
.cuav-nav-dropdown{
  position:absolute; top:calc(100% + 6px); left:0; min-width:190px;
  max-height:calc(100vh - 80px); overflow:auto;
  background:#1e293b; border:1px solid #334155; border-radius:8px;
  box-shadow:0 8px 24px rgba(0,0,0,.28);
  list-style:none; margin:0; padding:6px 0; display:none; z-index:1001;
}
.cuav-nav-item:hover .cuav-nav-dropdown,
.cuav-nav-item.open .cuav-nav-dropdown{display:block;}
.cuav-nav-dropdown li{margin:0;}
.cuav-nav-dropdown a{
  display:block; padding:7px 16px; color:#e2e8f0; font-size:14px;
  text-decoration:none; white-space:nowrap;
}
.cuav-nav-dropdown a:hover{color:#60a5fa; background:#334155;}
.cuav-nav-dropdown a.current-lang{
  color:#60a5fa; font-weight:600;
}
.cuav-header-tools{display:flex; align-items:center; gap:4px; margin-left:8px; position:relative;}
.cuav-tool{
  width:34px; height:34px; display:flex; align-items:center; justify-content:center;
  border:0; background:transparent; border-radius:6px; cursor:pointer; color:#cbd5e1;
}
.cuav-tool:hover{background:rgba(255,255,255,.1); color:#60a5fa;}
.cuav-menu-toggle{display:none;}
.cuav-theme .icon-sun{display:block}
.cuav-theme .icon-moon{display:none}
.cuav-lang-switch{
  display:flex; align-items:center; padding:7px 10px; border:0; border-radius:6px;
  background:transparent; color:#e2e8f0; font-size:14px; font-weight:500;
  text-decoration:none; white-space:nowrap; cursor:pointer; font-family:inherit;
}
.cuav-lang-switch:hover{background:rgba(255,255,255,.1); color:#60a5fa;}

@media(max-width:980px){
  .cuav-nav{display:none; position:absolute; top:49px; left:0; right:0; background:#0f172a;
    border-bottom:1px solid #1e293b; padding:10px 18px 18px; flex-direction:column;
    align-items:flex-start; gap:4px; box-shadow:0 12px 24px rgba(0,0,0,.28); max-height:calc(100vh - 49px); overflow:auto;}
  .cuav-header.open .cuav-nav{display:flex;}
  .cuav-nav-dropdown{position:static; display:none; box-shadow:none; border:0;
    padding:0 0 0 12px; background:transparent !important;}
  .cuav-nav-item{width:100%;}
  .cuav-nav-item.open .cuav-nav-dropdown{display:block;}
  .cuav-nav-title{width:100%; justify-content:space-between; padding-left:0;}
  .cuav-menu-toggle{display:flex; margin-left:auto;}
  .cuav-header-tools{margin-left:12px;}
}

/* =========================================================
   2. GitBook 整体布局适配
   ========================================================= */
body{padding-top:49px !important;}
.book{
  background:var(--bg) !important;
}
.book-body{
  margin-top:0 !important;
  background:var(--bg) !important;
}
.book-body .body-inner{
  background:var(--bg) !important;
}
.book.with-summary .book-body{
  left:300px;
}

/* =========================================================
   3. 左侧文档目录（卡片化）
   ========================================================= */
.book-summary{
  background:#f8fafc !important;
  border-right:1px solid var(--border) !important;
  top:0 !important;
  bottom:0 !important;
  z-index:100 !important;
}
.book-summary .cuav-side-title{
  font-weight:700; color:#1e3a8a; font-size:15px;
  margin:16px 18px 10px; display:flex; align-items:center; gap:6px;
}
.book-summary .cuav-side-search{
  width:calc(100% - 36px); margin:0 18px 12px; padding:8px 11px;
  border:1px solid var(--border); border-radius:9px;
  background:#f8fafc; color:var(--text); font-size:13px; outline:none;
  box-sizing:border-box;
}
.book-summary .cuav-side-search:focus{
  border-color:var(--accent); background:#fff;
}
.book-summary ul.summary{
  padding:0 14px 16px; list-style:none;
}
.book-summary ul.summary li{
  margin:5px 0;
}
.book-summary ul.summary li.chapter > a,
.book-summary ul.summary li.chapter > span{
  display:block; padding:9px 12px 9px 30px;
  border:1px solid #dbeafe; border-radius:10px;
  background:#f0f9ff; color:#334155; font-size:14.5px; font-weight:600;
  line-height:1.4; text-decoration:none; position:relative;
  transition:background .15s, border-color .15s, color .15s;
}
.book-summary ul.summary li.chapter > a:hover{
  background:#e0f2fe; border-color:#bfdbfe; color:#1d4ed8; text-decoration:none;
}
.book-summary ul.summary li.chapter.active > a{
  background:#dcfce7 !important; border-color:#86efac !important;
  color:#15803d !important; font-weight:700;
}
.book-summary ul.summary li.header > span,
.book-summary ul.summary li.header > a{
  background:transparent !important; border-color:transparent !important;
  color:#9ca3af; font-size:0.78rem; font-weight:600;
  text-transform:uppercase; letter-spacing:.5px; padding-left:12px;
}
.book-summary ul.summary ul.articles{
  list-style:none; margin:4px 0 8px; padding:0 0 0 22px; position:relative;
}
.book-summary ul.summary ul.articles::before{
  content:''; position:absolute; left:11px; top:4px; bottom:4px;
  width:1px; background:#e2e8f0;
}
.book-summary ul.summary ul.articles li.chapter{
  margin:4px 0;
}
.book-summary ul.summary ul.articles li.chapter > a,
.book-summary ul.summary ul.articles li.chapter > span{
  padding-left:42px; font-weight:500;
}
.book-summary ul.summary ul.articles ul.articles li.chapter > a,
.book-summary ul.summary ul.articles ul.articles li.chapter > span{
  padding-left:54px; font-weight:400;
}
.book-summary ul.summary ul.articles li.chapter.active > a{
  background:#dcfce7 !important; border-color:#86efac !important;
  color:#15803d !important;
}

/* 三角折叠控件 */
.book-summary ul.summary li.chapter.has-children > a{
  cursor:pointer;
}
.book-summary ul.summary li.chapter.has-children > a .cuav-toggle{
  position:absolute; left:9px; top:50%;
  transform:translateY(-50%) rotate(0deg);
  width:16px; height:16px; display:inline-flex;
  align-items:center; justify-content:center;
  font-size:10px; line-height:1; color:#64748b;
  cursor:pointer; transition:transform .15s ease, color .15s;
  user-select:none;
}
.book-summary ul.summary li.chapter.has-children.collapsed > a .cuav-toggle{
  transform:translateY(-50%) rotate(-90deg);
}
.book-summary ul.summary li.chapter.has-children > a:hover .cuav-toggle{
  color:#1d4ed8;
}
.book-summary ul.summary li.chapter.active.has-children > a .cuav-toggle{
  color:#15803d;
}
.book-summary ul.summary li.chapter.has-children.collapsed > ul.articles{
  display:none !important;
}

/* =========================================================
   4. 右侧文章大纲（固定卡片）
   ========================================================= */
.cuav-page-toc{
  position:fixed; top:67px; right:20px; width:240px;
  max-height:calc(100vh - 96px); overflow-y:auto; z-index:10;
  background:var(--card); border:1px solid var(--border); border-radius:16px;
  padding:18px 16px; box-shadow:0 8px 30px rgba(15,23,42,.06);
  font-size:13.5px; line-height:1.5;
}
.cuav-page-toc .cuav-toc-title{
  font-weight:700; color:#1e3a8a; font-size:15px;
  margin:2px 4px 12px; display:flex; align-items:center; gap:6px;
}
.cuav-page-toc .cuav-toc-list{
  list-style:none; margin:0; padding:0;
}
.cuav-page-toc .cuav-toc-list li{
  margin:6px 0; position:relative;
}
.cuav-page-toc .cuav-toc-link{
  display:block; padding:7px 12px 7px 30px;
  border:1px solid #dbeafe; border-radius:9px;
  background:#f0f9ff; font-size:13.5px; color:#475569;
  line-height:1.5; text-decoration:none;
  transition:background .15s, border-color .15s, color .15s;
}
.cuav-page-toc .cuav-toc-link.level-3{margin-left:10px;}
.cuav-page-toc .cuav-toc-link.level-4{margin-left:20px;}
.cuav-page-toc .cuav-toc-link:hover{
  background:#e0f2fe; border-color:#bfdbfe; color:#1d4ed8; text-decoration:none;
}
.cuav-page-toc .cuav-toc-link.active{
  background:#dcfce7; border-color:#86efac; color:#15803d; font-weight:700;
}
.cuav-page-toc .cuav-toc-children{
  list-style:none; margin:4px 0 6px; padding:0;
}
.cuav-page-toc .cuav-toc-toggle{
  position:absolute; left:8px; top:50%;
  transform:translateY(-50%) rotate(0deg);
  width:16px; height:16px; display:inline-flex;
  align-items:center; justify-content:center;
  font-size:10px; line-height:1; color:#64748b;
  cursor:pointer; transition:transform .15s ease, color .15s;
  user-select:none;
}
.cuav-page-toc li.has-children.collapsed > .cuav-toc-toggle{
  transform:translateY(-50%) rotate(-90deg);
}
.cuav-page-toc li.has-children.collapsed > .cuav-toc-children{
  display:none;
}

/* 右侧大纲存在时才预留空间；无大纲页面正文铺满整宽，避免右侧空白 */
@media (min-width: 1151px){
  .cuav-has-toc .book .book-body .page-inner{
    margin-right:276px !important; /* 原 280，让正文卡片与 TOC 间距从 20px 降到约 16px（小 20%） */
  }
}
@media (max-width: 1150px){
  .cuav-page-toc{display:none;}
}

/* =========================================================
   5. 正文区域卡片化 + 排版
   ========================================================= */
.page-inner{
  background:var(--card) !important;
  border:1px solid var(--border); border-radius:16px;
  padding:40px 46px 48px !important;
  box-shadow:0 8px 30px rgba(15,23,42,.06);
  margin:20px 20px 40px !important;
}
@media (max-width: 980px){
  .page-inner{
    margin:16px 12px 32px !important;
    padding:28px 22px 32px !important;
  }
}
@media (max-width: 640px){
  .page-inner{
    margin:12px 8px 24px !important;
    padding:24px 18px !important;
  }
}

.markdown-section{
  color:var(--text);
}
.markdown-section a{
  color:var(--accent); text-decoration:none;
}
.markdown-section a:hover{text-decoration:underline;}
.markdown-section p{margin:12px 0;}
.markdown-section ul,
.markdown-section ol{padding-left:24px; margin:12px 0;}
.markdown-section li{margin:6px 0;}
.markdown-section hr{
  border:none; border-top:1px dashed var(--border); margin:30px 0;
}
.markdown-section strong{color:#111827;}

/* 标题 */
.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4,
.markdown-section h5,
.markdown-section h6{
  line-height:1.35; scroll-margin-top:80px;
}
.markdown-section h1{
  font-size:30px; margin:0 0 18px; padding-bottom:14px;
  border-bottom:2px solid var(--border);
  background:linear-gradient(90deg,#1e3a8a,#2563eb);
  -webkit-background-clip:text; background-clip:text; color:transparent;
}
.markdown-section h2{
  font-size:23px; margin:38px 0 14px; padding-left:12px;
  border-left:4px solid var(--accent); color:#1e3a8a;
}
.markdown-section h3{
  font-size:19px; margin:28px 0 10px; color:#1d4ed8;
}
.markdown-section h4{
  font-size:16.5px; margin:22px 0 8px; color:#334155; font-weight:700;
}

/* 行内代码 */
.markdown-section code{
  background:var(--code-bg); border:1px solid var(--code-border);
  border-radius:5px; padding:1px 6px; font-size:13.5px;
  font-family:"JetBrains Mono","Fira Code",Consolas,"Courier New",monospace;
  color:#b91c1c;
}
.markdown-section a code{color:inherit;}

/* 代码块 */
.markdown-section pre{
  background:#0f172a; color:#e2e8f0; border-radius:12px;
  padding:18px 20px; overflow:auto; margin:16px 0;
  font-size:13.5px; line-height:1.6;
  font-family:"JetBrains Mono","Fira Code",Consolas,"Courier New",monospace;
  box-shadow:inset 0 0 0 1px rgba(148,163,184,.2);
}
.markdown-section pre code{
  background:none; color:inherit; padding:0; border:none;
  font-size:inherit;
}
.markdown-section pre .token.tag{color:#7dd3fc;}
.markdown-section pre .token.punctuation{color:#94a3b8;}
.markdown-section pre .token.prolog{color:#c084fc;}
.markdown-section pre .token.attr-name{color:#fbbf24;}
.markdown-section pre .token.attr-value,
.markdown-section pre .token.string{color:#86efac;}

/* 表格 */
.markdown-section .table-wrap,
.markdown-section table{
  width:100%; overflow-x:auto; margin:18px 0;
  border:1px solid var(--border); border-radius:10px;
  box-sizing:border-box; display:block;
}
.markdown-section table{
  display:table; border-collapse:collapse;
  min-width:680px; font-size:14.5px; background:var(--card);
}
.markdown-section table thead th{
  background:#f1f5f9; color:#0f172a; font-weight:700;
  padding:11px 14px; border-bottom:2px solid #dbe2ea; text-align:left;
}
.markdown-section table td{
  padding:10px 14px; border-bottom:1px solid #eef1f5; vertical-align:top;
}
.markdown-section table tbody tr:nth-child(even){background:#fafbfc;}
.markdown-section table tbody tr:hover{background:var(--accent-soft);}
.markdown-section table tbody tr:last-child td{border-bottom:none;}

/* 引用块 */
.markdown-section blockquote{
  border-left:4px solid #cbd5e1; background:#f8fafc;
  margin:18px 0; padding:12px 18px;
  border-radius:0 10px 10px 0; color:#475569;
}
.markdown-section blockquote p{margin:6px 0;}

/* 图片 / figure */
.markdown-section img{
  max-width:100%; height:auto;
  border:1px solid var(--border); border-radius:12px;
  box-shadow:0 6px 18px rgba(15,23,42,.1);
  cursor:zoom-in; background:#fff;
}
.markdown-section figure{
  margin:20px 0; text-align:center;
}
.markdown-section figcaption{
  margin-top:8px; font-size:13px; color:var(--muted);
}

/* 页内 TOC（GitBook 自动生成） */
.markdown-section .toc{
  background:#f8fafc; border:1px solid var(--border);
  border-radius:12px; padding:16px 20px; margin:0 0 26px;
}
.markdown-section .toc-title{
  font-weight:700; color:#1e3a8a; margin-bottom:8px; font-size:15px;
}
.markdown-section .toc ul{list-style:none; margin:0; padding:0;}
.markdown-section .toc li{margin:4px 0;}
.markdown-section .toc a{color:#334155; font-size:14.5px; text-decoration:none;}
.markdown-section .toc a:hover{color:var(--accent);}
.markdown-section .toc .toc-h3{padding-left:18px;}
.markdown-section .toc .toc-h3 a{font-size:13.5px; color:#64748b;}

/* 分页导航 */
.book .book-body .navigation{
  color:var(--muted);
}
.book .book-body .navigation:hover{
  color:var(--accent);
}

/* 页脚 */
.cuav-footer{
  text-align:center; color:var(--muted); font-size:13px;
  margin-top:26px; padding-top:18px; border-top:1px solid var(--border);
}
.cuav-footer a{color:var(--accent);}

/* 图片灯箱 */
#lb{
  position:fixed; inset:0; background:rgba(15,23,42,.88);
  display:none; align-items:center; justify-content:center;
  z-index:9999; cursor:zoom-out;
}
#lb img{
  max-width:92%; max-height:92%; border-radius:8px;
  box-shadow:0 12px 40px rgba(0,0,0,.5);
}

/* =========================================================
   6. 夜间模式
   ========================================================= */
html[data-theme='dark']{
  --bg:#0f172a; --card:#1e293b; --text:#e2e8f0; --muted:#94a3b8;
  --accent:#60a5fa; --accent-soft:rgba(96,165,250,.12); --border:#334155;
  --code-bg:#1e293b; --code-border:#334155;
}
html[data-theme='dark'] body{background:var(--bg); color:var(--text);}
html[data-theme='dark'] .book,
html[data-theme='dark'] .book-body,
html[data-theme='dark'] .book-body .body-inner{
  background:var(--bg) !important;
}

/* header dark */
html[data-theme='dark'] .cuav-theme .icon-sun{display:none}
html[data-theme='dark'] .cuav-theme .icon-moon{display:block}

/* sidebar dark */
html[data-theme='dark'] .book-summary{
  background:#111111 !important;
  border-right-color:#262626 !important;
}
html[data-theme='dark'] .book-summary .cuav-side-title{color:#e5e7eb;}
html[data-theme='dark'] .book-summary .cuav-side-search{
  background:#171717; border-color:#262626; color:#d2d2d2;
}
html[data-theme='dark'] .book-summary .cuav-side-search:focus{
  border-color:#2563eb; background:#0d0d0d;
}
html[data-theme='dark'] .book-summary ul.summary li.chapter > a,
html[data-theme='dark'] .book-summary ul.summary li.chapter > span{
  background:#0d0d0d; border-color:#262626; color:#cfcfcf;
}
html[data-theme='dark'] .book-summary ul.summary li.chapter > a:hover{
  background:#1f1f1f; border-color:#475569; color:#fff;
}
html[data-theme='dark'] .book-summary ul.summary li.chapter.active > a{
  background:#14532d !important; border-color:#22c55e !important; color:#86efac !important;
}
html[data-theme='dark'] .book-summary ul.summary li.chapter.has-children > a .cuav-toggle{color:#9ca3af;}
html[data-theme='dark'] .book-summary ul.summary li.chapter.has-children > a:hover .cuav-toggle{color:#fff;}
html[data-theme='dark'] .book-summary ul.summary ul.articles::before{background:#262626;}

/* right TOC dark */
html[data-theme='dark'] .cuav-page-toc{
  background:var(--card); border-color:var(--border);
  box-shadow:0 8px 30px rgba(0,0,0,.25);
}
html[data-theme='dark'] .cuav-page-toc .cuav-toc-title{color:#93c5fd;}
html[data-theme='dark'] .cuav-page-toc .cuav-toc-link{
  background:var(--card); border-color:var(--border); color:#cbd5e1;
}
html[data-theme='dark'] .cuav-page-toc .cuav-toc-link.level-3{color:#94a3b8;}
html[data-theme='dark'] .cuav-page-toc .cuav-toc-link:hover{
  background:#334155; border-color:#475569; color:#e2e8f0;
}
html[data-theme='dark'] .cuav-page-toc .cuav-toc-link.active{
  background:#14532d; border-color:#22c55e; color:#86efac;
}

/* article dark */
html[data-theme='dark'] .page-inner{
  background:var(--card) !important; border-color:var(--border);
}
html[data-theme='dark'] .markdown-section{color:var(--text);}
html[data-theme='dark'] .markdown-section h1{
  background:linear-gradient(90deg,#93c5fd,#60a5fa);
  -webkit-background-clip:text; background-clip:text; color:transparent;
  border-bottom-color:var(--border);
}
html[data-theme='dark'] .markdown-section h2{color:#93c5fd; border-left-color:var(--accent);}
html[data-theme='dark'] .markdown-section h3{color:#60a5fa;}
html[data-theme='dark'] .markdown-section h4{color:#cbd5e1;}
html[data-theme='dark'] .markdown-section strong{color:#f1f5f9;}
html[data-theme='dark'] .markdown-section a{color:var(--accent);}
html[data-theme='dark'] .markdown-section code{
  background:var(--code-bg); border-color:var(--code-border); color:#fca5a5;
}
html[data-theme='dark'] .markdown-section pre{
  background:#020617; color:#e2e8f0;
  box-shadow:inset 0 0 0 1px rgba(148,163,184,.15);
}
html[data-theme='dark'] .markdown-section .toc{
  background:#1e293b; border-color:var(--border);
}
html[data-theme='dark'] .markdown-section .toc-title{color:#93c5fd;}
html[data-theme='dark'] .markdown-section .toc a{color:#cbd5e1;}
html[data-theme='dark'] .markdown-section .toc a:hover{color:var(--accent);}
html[data-theme='dark'] .markdown-section .toc .toc-h3 a{color:#94a3b8;}
html[data-theme='dark'] .markdown-section blockquote{
  background:#1e293b; border-left-color:#475569; color:#cbd5e1;
}
html[data-theme='dark'] .markdown-section table{
  background:var(--card); border-color:var(--border);
}
html[data-theme='dark'] .markdown-section table thead th{
  background:#334155; color:#f1f5f9; border-bottom-color:#475569;
}
html[data-theme='dark'] .markdown-section table td{
  border-bottom-color:#334155; color:var(--text);
}
html[data-theme='dark'] .markdown-section table tbody tr:nth-child(even){background:#0f172a;}
html[data-theme='dark'] .markdown-section table tbody tr:hover{background:var(--accent-soft);}
html[data-theme='dark'] .markdown-section hr{border-color:var(--border);}
html[data-theme='dark'] .cuav-footer{border-top-color:var(--border); color:var(--muted);}
html[data-theme='dark'] #lb{background:rgba(2,6,23,.92);}

/* GitBook 自带夜间类兼容：也响应 data-theme */
.book.color-theme-2,
body .book.color-theme-2{
  background:var(--bg) !important;
}
