:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;

  --article-width: 820px;   /* 接近 A4 阅读宽度 */
  --right-width: 260px;
  --gap: 24px;
}

/* 全局背景 */
body {
  background: var(--bg) !important;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  line-height: 1.8;
}

/* 顶部导航简单化 */
#navigator,
#blogTitle {
  max-width: 1160px;
  margin-left: auto;
  margin-right: auto;
}

/* 页面主体 */
#home {
  max-width: calc(var(--article-width) + var(--right-width) + var(--gap));
  margin: 0 auto !important;
  background: transparent !important;
}

/* 主体变成 中间正文 + 右侧栏 */
#main {
  display: grid !important;
  grid-template-columns: minmax(0, var(--article-width)) var(--right-width);
  gap: var(--gap);
  align-items: start;
}

#mainContent {
  float: none !important;
  width: auto !important;
  min-width: 0;
}

#sideBar {
  float: none !important;
  width: auto !important;
  position: sticky;
  top: 24px;
}

/* 正文卡片：A4 纸张感 */
#post_detail,
.post,
.day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

#post_detail {
  padding: 48px 56px;
}

/* 标题 */
.postTitle,
#cb_post_title_url {
  font-size: 30px !important;
  font-weight: 800 !important;
  color: #111827 !important;
  text-decoration: none !important;
  line-height: 1.35;
}

#cnblogs_post_body h1 {
  margin-top: 2.2em;
  padding-bottom: 0.35em;
  border-bottom: 2px solid var(--border);
  font-size: 28px;
}

#cnblogs_post_body h2 {
  margin-top: 2em;
  padding-left: 12px;
  border-left: 4px solid var(--accent);
  font-size: 23px;
}

#cnblogs_post_body h3 {
  margin-top: 1.7em;
  font-size: 19px;
}

#cnblogs_post_body h1,
#cnblogs_post_body h2,
#cnblogs_post_body h3 {
  scroll-margin-top: 24px;
}

/* 段落 */
#cnblogs_post_body p {
  margin: 1em 0;
  font-size: 16px;
}

/* 图片：限制宽度，居中，好看一点 */
#cnblogs_post_body img {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  margin: 24px auto;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

/* 引用 */
#cnblogs_post_body blockquote {
  margin: 1.5em 0;
  padding: 12px 18px;
  border-left: 4px solid var(--accent);
  background: #f8fafc;
  color: #475569;
  border-radius: 8px;
}

/* 代码 */
#cnblogs_post_body pre {
  padding: 18px;
  border-radius: 12px;
  background: #0f172a !important;
  color: #e5e7eb !important;
  overflow-x: auto;
  font-size: 14px;
}

#cnblogs_post_body code {
  font-family: "JetBrains Mono", "Consolas", monospace;
}

/* 表格 */
#cnblogs_post_body table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 15px;
}

#cnblogs_post_body th,
#cnblogs_post_body td {
  border: 1px solid var(--border);
  padding: 10px 12px;
}

#cnblogs_post_body th {
  background: #f8fafc;
}

/* 右侧栏卡片 */
#sideBarMain,
.newsItem,
.catList,
#blog-calendar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

#sideBar h3 {
  font-size: 16px;
  margin-top: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* 左侧目录 */
/* 给左侧目录预留空间 */
@media (min-width: 1500px) {
  #home {
    max-width: 1800px !important;
    padding-left: 600px;
    box-sizing: border-box;
  }
}

/* 左侧目录整体 */
#my-toc {
  position: fixed;
  top: 90px;
  left: 24px;
  width: 220px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  z-index: 9999;
  padding: 0;
}

/* 目录头部 */
#my-toc .toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eef2f7;
  font-size: 15px;
  font-weight: 700;
  color: #475569;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}

#my-toc .toc-toggle {
  font-size: 13px;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}

/* 目录内容区 */
#my-toc nav {
  position: relative;
  padding: 14px 0 14px 0;
}

/* 左边竖线 */
#my-toc nav::before {
  content: "";
  position: absolute;
  left: 27px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: #e2e8f0;
  border-radius: 1px;
}

/* 每一项 */
#my-toc a {
  position: relative;
  display: block;
  margin: 0;
  padding: 8px 14px 8px 42px;
  color: #64748b;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.5;
  transition: all 0.2s ease;
  word-break: break-word;
}

/* 圆点 */
#my-toc a::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 17px;
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  z-index: 1;
}

/* hover / active */
#my-toc a:hover {
  color: #2563eb;
  background: #f8fbff;
}

#my-toc a.active {
  color: #2563eb;
  font-weight: 600;
  background: #eff6ff;
}

#my-toc a.active::before {
  background: #2563eb;
}

/* 不同层级缩进 */
#my-toc .toc-h1 {
  padding-left: 42px;
  font-weight: 600;
}

#my-toc .toc-h2 {
  padding-left: 56px;
  font-size: 14px;
}

#my-toc .toc-h2::before {
  left: 36px;
}

#my-toc .toc-h3 {
  padding-left: 72px;
  font-size: 13px;
  color: #94a3b8;
}

#my-toc .toc-h3::before {
  left: 50px;
  width: 6px;
  height: 6px;
}

/* 收起后的状态 */
#my-toc.collapsed {
  width: 68px;
}

#my-toc.collapsed nav {
  display: none;
}

#my-toc.collapsed .toc-header {
  justify-content: center;
}

#my-toc.collapsed .toc-title-text {
  display: none;
}

/* 小屏隐藏 */
@media (max-width: 1199px) {
  #my-toc {
    display: none !important;
  }

  #home {
    padding-left: 0 !important;
  }
}




/* 平板/手机：单栏 */
@media (max-width: 960px) {
  #home {
    width: auto !important;
    margin: 0 12px !important;
  }

  #main {
    display: block !important;
  }

  #post_detail {
    padding: 28px 20px;
    border-radius: 14px;
  }

  #sideBar {
    position: static;
    margin-top: 24px;
  }
}

/* 打印 / 导出 PDF：真正 A4 */
@media print {
  @page {
    size: A4;
    margin: 18mm 16mm;
  }

  body {
    background: #fff !important;
  }

  #navigator,
  #blogTitle,
  #sideBar,
  #my-toc,
  #comment_form,
  #blog_post_info,
  #under_post_news,
  #under_post_kb {
    display: none !important;
  }

  #home,
  #main,
  #mainContent,
  #post_detail {
    width: auto !important;
    max-width: none !important;
    display: block !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #cnblogs_post_body img {
    box-shadow: none !important;
  }
}

