:root {
  --primary: #1e63c8;
  --primary-dark: #15468f;
  --accent: #0aa3b4;
  --bg: #f5f8fc;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(20, 50, 100, 0.08);
  --nav-h: 64px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.35; color: #0f2540; }
img { max-width: 100%; }

/* ---------- 导航 ---------- */
.nav-bar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(120deg, var(--primary-dark), var(--primary));
  color: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.12);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; height: var(--nav-h);
  display: flex; align-items: center; gap: 18px; padding: 0 16px;
}
.brand { color: #fff; font-weight: 800; font-size: 18px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav-toggle {
  display: none; background: transparent; border: 0; color: #fff;
  font-size: 22px; cursor: pointer;
}
.nav-list { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; flex: 1; }
.nav-item { position: relative; }
.nav-item > a, .nav-sub-btn {
  display: block; padding: 10px 14px; color: #eaf2ff; background: transparent;
  border: 0; font-size: 15px; cursor: pointer; border-radius: 8px;
}
.nav-item > a:hover, .nav-sub-btn:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.submenu {
  position: absolute; top: 100%; left: 0; min-width: 200px;
  background: #fff; border-radius: 10px; box-shadow: var(--shadow);
  padding: 8px; display: none; flex-direction: column; z-index: 60;
}
.nav-item.has-sub:hover .submenu, .nav-item.has-sub.open .submenu { display: flex; }
.submenu a { color: var(--text); padding: 8px 12px; border-radius: 6px; font-size: 14px; }
.submenu a:hover { background: var(--bg); }

/* ---------- 容器与布局 ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.article-layout, .list-layout, .home-wrap { --h2-inset: 16px; padding-top: 20px; padding-bottom: 40px; }
.page-wrap { --h2-inset: 48px; padding-top: 24px; padding-bottom: 48px; }
.layout-grid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 32px; align-items: start; }
/* 列表页：分类侧栏固定 240px 居左，文章列表占满剩余宽度，避免中间留白 */
.list-layout .layout-grid { grid-template-columns: 240px minmax(0, 1fr); }
.content-main, .cat-content, .page-main { padding-left: var(--h2-inset); }
.page-main { max-width: 880px; }
.toc-aside { position: sticky; top: calc(var(--nav-h) + 16px); max-height: calc(100vh - 100px); overflow-y: auto; }

@media (max-width: 1024px) {
  .layout-grid { grid-template-columns: 1fr; }
  .list-layout .layout-grid { grid-template-columns: 1fr; }
  .toc-aside { position: static; max-height: none; }
}

/* ---------- 面包屑 ---------- */
.breadcrumb { padding-left: var(--h2-inset); margin: 4px 0 18px; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; font-size: 13px; color: var(--muted); }
.breadcrumb li::after { content: "›"; margin-left: 6px; color: #cbd5e1; }
.breadcrumb li:last-child::after { content: ""; }
.breadcrumb a { color: var(--muted); }

/* ---------- 目录 / 分类折叠面板 ---------- */
.toc-panel, .cat-panel {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 12px 14px; margin-bottom: 16px;
}
.toc-panel summary, .cat-panel summary {
  cursor: pointer; font-weight: 700; color: var(--primary-dark);
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.toc-panel summary::after, .cat-panel summary::after { content: "▾"; transition: transform .2s; }
.toc-panel[open] summary::after, .cat-panel[open] summary::after { transform: rotate(180deg); }
.toc-nav ul, .category-list { list-style: none; margin: 10px 0 0; padding-left: 0; }
.toc-nav li a { display: block; padding: 4px 0; font-size: 14px; color: var(--text); }
.toc-lv3 { padding-left: 16px !important; font-size: 13px; }
.category-list li a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.category-list li a:hover, .category-list li a.active { background: var(--bg); color: var(--primary); font-weight: 600; }

/* ---------- 正文样式 ---------- */
.content-main h1 { font-size: 30px; margin: 0 0 12px; }
.content-main h2 { font-size: 22px; margin: 34px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.content-main h3 { font-size: 18px; margin: 24px 0 8px; }
.content-main p { margin: 12px 0; }
.content-main blockquote {
  background: #eef5ff; border-left: 4px solid var(--primary);
  margin: 16px 0; padding: 12px 16px; border-radius: 0 8px 8px 0; color: #244;
}
.content-main table, .page-main table, table.data {
  width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px;
  background: var(--surface); border: 1px solid #cbd5e1; border-radius: var(--radius); overflow: hidden;
}
.content-main th, .content-main td, .page-main th, .page-main td,
table.data th, table.data td { border: 1px solid #cbd5e1; padding: 10px 12px; text-align: left; }
.content-main thead th, .page-main thead th, table.data th { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.content-main tbody tr:nth-child(even), .page-main tbody tr:nth-child(even), table.data tbody tr:nth-child(even) { background: #f7fafd; }
.content-main code { background: #eef2f7; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* ---------- FAQ ---------- */
.faq-block { margin-top: 28px; }
.faq-block h2 { font-size: 22px; }
.faq-item { border: 1px solid var(--border); border-radius: 10px; margin: 10px 0; background: var(--surface); }
.faq-item summary { cursor: pointer; padding: 12px 16px; font-weight: 600; }
.faq-a { padding: 0 16px 12px; color: #334; }

/* ---------- 相关阅读 / callout ---------- */
.related { margin-top: 30px; }
.related-list { list-style: none; padding-left: 0; }
.related-list li { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.callout { border: 1px solid var(--border); border-left: 4px solid var(--accent); background: #f3fbfc; border-radius: 8px; padding: 14px 16px; margin: 18px 0; }
.callout-title { font-weight: 700; color: var(--accent); margin: 0 0 6px; }

/* ---------- 悬浮胶囊 ---------- */
.capsule {
  position: fixed; right: 18px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 10px; z-index: 80;
}
.cap-btn {
  display: flex; align-items: center; gap: 6px; width: 56px; height: 56px;
  justify-content: center; border: 0; border-radius: 28px; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
  box-shadow: var(--shadow); font-size: 13px; flex-direction: column;
}
.cap-btn:hover { transform: scale(1.05); }
.cap-ico { font-size: 18px; line-height: 1; }

/* ---------- 名片弹窗 ---------- */
.card-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.card-modal[hidden] { display: none; }
.card-modal-mask { position: absolute; inset: 0; background: rgba(15,37,64,.55); }
.card-modal-box { position: relative; background: #fff; padding: 8px; border-radius: 10px; box-shadow: var(--shadow); }
.card-close { position: absolute; top: -12px; right: -12px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: #fff; cursor: pointer; box-shadow: var(--shadow); font-size: 18px; }
.card-img { display: block; width: 300px; height: 500px; object-fit: contain; }

/* ---------- 首页 ---------- */
.hero { background: linear-gradient(120deg, var(--primary-dark), var(--accent)); color: #fff; padding: 64px 16px; text-align: center; }
.hero-inner { max-width: 860px; margin: 0 auto; }
.hero h1 { color: #fff; font-size: 36px; margin: 0 0 14px; }
.hero-sub { font-size: 17px; opacity: .95; }
.hero-cta { margin-top: 24px; display: flex; gap: 14px; justify-content: center; }
.btn { display: inline-block; padding: 12px 26px; border-radius: 30px; background: #fff; color: var(--primary-dark); font-weight: 700; }
.btn:hover { text-decoration: none; }
.btn.ghost { background: transparent; border: 2px solid #fff; color: #fff; }
.section { max-width: 1200px; margin: 0 auto; padding: 40px 16px; }
.sec-title { font-size: 24px; margin: 0 0 20px; border-left: 5px solid var(--primary); padding-left: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); color: var(--text); }
.card:hover { transform: translateY(-3px); text-decoration: none; }
.card h3 { margin: 0 0 8px; color: var(--primary-dark); }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.tag-cloud { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; padding: 0; }
.tag { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 6px 14px; font-size: 14px; }

/* ---------- 列表页 ---------- */
.post-list { list-style: none; padding: 0; }
.post-item { padding: 18px 0; border-bottom: 1px solid var(--border); }
.post-link h3 { margin: 0 0 4px; }
.post-meta { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.post-desc { margin: 0; color: #475569; }
.pagination { margin: 24px 0; display: flex; gap: 14px; align-items: center; }
.list-intro { color: var(--muted); }

/* ---------- 页脚 ---------- */
.site-footer { background: #0f2540; color: #cbd5e1; padding: 40px 16px 0; margin-top: 40px; }
.footer-inner { max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; }
.footer-col h3, .footer-col h4 { color: #fff; }
.footer-col ul { list-style: none; padding: 0; }
.footer-col li { margin: 6px 0; }
.footer-col a { color: #9fc0ef; }
.footer-bottom { text-align: center; padding: 18px; border-top: 1px solid rgba(255,255,255,.1); margin-top: 24px; font-size: 13px; }

@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .nav { display: none; width: 100%; }
  .nav.open { display: block; }
  .nav-list { flex-direction: column; padding: 8px 0; }
  .submenu { position: static; box-shadow: none; background: rgba(255,255,255,.06); }
  .nav-item.has-sub:hover .submenu { display: none; }
  .nav-item.has-sub.open .submenu { display: flex; }
  .hero h1 { font-size: 28px; }
  .capsule { right: 10px; }
  .cap-btn { width: 48px; height: 48px; }
}
