/* ================================================
   0. 现代字体 + 全局过渡
   ================================================ */
body {
  font-family: 'PingFang SC','Noto Sans SC','Microsoft YaHei',sans-serif !important;
  -webkit-font-smoothing: antialiased !important;
  letter-spacing: 0.2px !important;
  font-size: var(--reader-font-size, 16px) !important;
}
body, #home, #home_wrap, #header_wrap {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.post-content p, #cnblogs_post_body p {
  line-height: 1.85 !important;
  margin: 12px 0 !important;
  font-size: var(--reader-font-size, 16px) !important;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(74,144,217,0.35); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(74,144,217,0.55); }
body.dark-mode ::-webkit-scrollbar-thumb { background: rgba(96,165,250,0.35); }

/* ================================================
   1. 阅读进度条
   ================================================ */
#read-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, #4a90d9, #7c3aed, #4a90d9);
  background-size: 200% auto;
  animation: progressShine 2s linear infinite;
  z-index: 999999; border-radius: 0 2px 2px 0;
  transition: width 0.1s;
}
#read-progress::after {
  content: attr(data-pct) '%';
  position: absolute; right: -4px; top: 8px;
  background: rgba(74,144,217,0.95); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  opacity: 0; transition: opacity 0.25s; white-space: nowrap;
}
#read-progress:hover::after, #read-progress.showing::after { opacity: 1; }
@keyframes progressShine {
  0%   { background-position: 0% center; }
  100% { background-position: 200% center; }
}

/* ================================================
   2. 页面淡入
   ================================================ */
#home { animation: fadeInPage 0.5s ease both; }
@keyframes fadeInPage {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================================================
   3. Header
   ================================================ */
#header {
  width: 100vw !important; max-width: 100vw !important;
  margin-left: calc(-50vw + 50%) !important;
  background-image: url('https://img2024.cnblogs.com/blog/3777328/202603/3777328-20260324211057874-295349986.jpg') !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  position: relative !important;
  min-height: 240px !important;
  padding-top: 46px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-end !important;
}
#header::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to bottom,
    rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.32) 60%, rgba(0,0,0,0.65) 100%);
  pointer-events: none; z-index: 0;
  transition: background 0.4s;
}
body.dark-mode #header::before {
  background: linear-gradient(to bottom,
    rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.68) 60%, rgba(0,0,0,0.88) 100%) !important;
}
#header > * { position: relative; z-index: 1; }

#blogTitle { padding: 8px 40px 6px !important; order: 2; }
#blogTitle a, #blogTitle h1, #blogTitle h2, #blogTitle .header-title {
  color: #fff !important;
  text-shadow: 0 2px 12px rgba(0,0,0,0.8) !important;
  font-size: 24px !important; font-weight: 700 !important;
  text-decoration: none !important;
}
#blogStats, .header-info {
  color: rgba(255,255,255,0.72) !important; font-size: 12px !important;
  padding: 2px 40px 0 !important; text-shadow: 0 1px 4px rgba(0,0,0,0.6) !important;
  order: 3;
}

#header-nav-inject {
  display: flex !important; flex-wrap: wrap !important;
  gap: 2px !important; padding: 6px 34px !important;
  order: 1;
}
#header-nav-inject a {
  color: rgba(255,255,255,0.90) !important; text-decoration: none !important;
  font-size: 13px !important; font-weight: 500 !important;
  padding: 5px 14px !important; border-radius: 4px !important;
  letter-spacing: 0.5px !important; transition: background 0.2s !important;
}
#header-nav-inject a:hover {
  background: rgba(255,255,255,0.18) !important; color: #fff !important;
}

#navigator { display: none !important; }

/* ================================================
   7. 代码块美化
   ================================================ */
.post-content pre, #cnblogs_post_body pre,
.post-content .cnblogs_code, #cnblogs_post_body .cnblogs_code,
.post-content div[class*="sourceCode"], #cnblogs_post_body div[class*="sourceCode"] {
  position: relative !important;
  border-radius: 8px !important;
  padding: 10px 16px !important;
  font-size: 13px !important;
  line-height: 1.7 !important;
  overflow-x: auto !important;
  background: #f6f8fa !important;
  border: 1px solid #e1e4e8 !important;
  margin: 12px 0 !important;
  box-shadow: none !important;
}

.post-content pre code, #cnblogs_post_body pre code,
.post-content .cnblogs_code pre, #cnblogs_post_body .cnblogs_code pre,
.post-content .cnblogs_code code, #cnblogs_post_body .cnblogs_code code,
.post-content .cnblogs_code span, #cnblogs_post_body .cnblogs_code span,
.post-content div[class*="sourceCode"] pre,
#cnblogs_post_body div[class*="sourceCode"] pre {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  font-size: inherit !important;
  font-family: 'Consolas','Monaco','Courier New',monospace !important;
  line-height: inherit !important;
}

.code-copy-btn {
  position: absolute; top: 6px; right: 8px;
  padding: 3px 10px; font-size: 11px; border-radius: 4px;
  background: rgba(74,144,217,0.12); color: #4a90d9;
  border: 1px solid rgba(74,144,217,0.3); cursor: pointer;
  transition: all 0.2s; user-select: none; font-family: inherit;
  opacity: 0.45; z-index: 2;
}
.post-content pre:hover .code-copy-btn,
#cnblogs_post_body pre:hover .code-copy-btn,
.post-content .cnblogs_code:hover .code-copy-btn,
#cnblogs_post_body .cnblogs_code:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: #4a90d9 !important; color: #fff !important; }

body.dark-mode .post-content pre,
body.dark-mode #cnblogs_post_body pre,
body.dark-mode .post-content .cnblogs_code,
body.dark-mode #cnblogs_post_body .cnblogs_code {
  background: #111827 !important; border-color: #374151 !important; color: #d1d5db !important;
}
body.dark-mode .post-content pre code,
body.dark-mode #cnblogs_post_body pre code { color: #d1d5db !important; }

.post-content code:not(pre code):not(.cnblogs_code code),
#cnblogs_post_body code:not(pre code):not(.cnblogs_code code) {
  background: rgba(74,144,217,0.10) !important;
  color: #c0392b !important;
  padding: 2px 7px !important;
  border-radius: 4px !important;
  font-size: 0.88em !important;
  font-family: 'Consolas','Monaco','Courier New',monospace !important;
  border: 1px solid rgba(74,144,217,0.15) !important;
}
body.dark-mode .post-content code:not(pre code):not(.cnblogs_code code),
body.dark-mode #cnblogs_post_body code:not(pre code):not(.cnblogs_code code) {
  background: rgba(96,165,250,0.15) !important;
  color: #f472b6 !important;
  border-color: rgba(96,165,250,0.25) !important;
}

/* ================================================
   8. 图片
   ================================================ */
.post-content img, #cnblogs_post_body img {
  max-width: 820px !important; width: 80% !important;
  display: block; margin: 16px auto !important;
  border-radius: 8px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.14);
  cursor: zoom-in !important;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s !important;
}
.post-content img:hover, #cnblogs_post_body img:hover {
  transform: scale(1.01) !important;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18) !important;
}

.post-content div[align="center"] em,
#cnblogs_post_body div[align="center"] em {
  display: inline-block !important;
  font-size: 13px !important;
  color: #6b7280 !important;
  font-style: normal !important;
  padding: 4px 14px !important;
  margin-top: 6px !important;
  background: linear-gradient(to right, transparent, #f3f4f6, transparent) !important;
  border-radius: 4px !important;
  letter-spacing: 0.3px !important;
  max-width: 85% !important;
}
body.dark-mode .post-content div[align="center"] em,
body.dark-mode #cnblogs_post_body div[align="center"] em {
  color: #9ca3af !important;
  background: linear-gradient(to right, transparent, #1f2937, transparent) !important;
}

#img-lightbox {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.92); z-index: 999990;
  align-items: center; justify-content: center;
  animation: lbFadeIn 0.2s ease;
}
#img-lightbox.show { display: flex; }
@keyframes lbFadeIn { from { opacity:0; } to { opacity:1; } }
#img-lightbox img {
  max-width: 90vw; max-height: 85vh;
  border-radius: 6px; box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  cursor: default; transform: none !important;
  width: auto !important; margin: 0 !important;
  transition: opacity 0.2s ease !important;
}
#img-lightbox img.switching { opacity: 0; }
#img-lightbox-close, .lb-nav {
  position: absolute; color: #fff; cursor: pointer;
  user-select: none; transition: all 0.2s;
  background: rgba(255,255,255,0.1); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
#img-lightbox-close {
  top: 24px; right: 28px;
  width: 42px; height: 42px; font-size: 22px; opacity: 0.8;
}
#img-lightbox-close:hover { opacity: 1; background: rgba(255,255,255,0.25); transform: rotate(90deg); }
.lb-nav {
  top: 50%; transform: translateY(-50%);
  width: 50px; height: 50px; font-size: 24px; opacity: 0.7;
}
.lb-nav:hover { opacity: 1; background: rgba(255,255,255,0.25); }
#lb-prev { left: 24px; }
#lb-next { right: 24px; }
#lb-counter {
  position: absolute; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.12); color: #fff;
  padding: 6px 18px; border-radius: 18px; font-size: 13px;
  backdrop-filter: blur(6px);
}

/* ================================================
   9. 表格 引用
   ================================================ */
.post-content table, #cnblogs_post_body table {
  margin: 16px auto !important; border-collapse: collapse;
  width: auto !important; max-width: 95%; font-size: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08); border-radius: 6px; overflow: hidden;
}
.post-content table th, #cnblogs_post_body table th {
  background: linear-gradient(135deg,#f0f4f8,#e8edf4);
  color: #333; font-weight: 700; padding: 10px 16px;
  border: 1px solid #dde3ea; text-align: center;
}
.post-content table td, #cnblogs_post_body table td {
  padding: 8px 16px; border: 1px solid #e4e9ef; text-align: center;
}
.post-content table tr:nth-child(even), #cnblogs_post_body table tr:nth-child(even) { background: #f9fbfc; }
.post-content table tr:hover, #cnblogs_post_body table tr:hover { background: #eef4fb; transition: background 0.15s; }

.post-content blockquote, #cnblogs_post_body blockquote {
  border-left: 4px solid #4a90d9; background: linear-gradient(to right,#f0f6ff,#fafcff);
  padding: 12px 18px; margin: 14px 0; color: #444; border-radius: 0 6px 6px 0;
}

/* ================================================
   10. 标题
   ================================================ */
.post-content h1, #cnblogs_post_body h1 {
  font-size: 1.8em !important; font-weight: 700 !important;
  color: #2c3e50 !important; padding: 10px 0 !important;
  border-bottom: 3px solid #4a90d9 !important; margin: 24px 0 16px !important;
}
.post-content h2, #cnblogs_post_body h2 {
  font-size: 1.5em !important; font-weight: 700 !important;
  color: #2c3e50 !important; padding: 4px 0 4px 14px !important;
  border-left: 5px solid #4a90d9 !important;
  background: linear-gradient(to right, rgba(74,144,217,0.08), transparent) !important;
  margin: 22px 0 14px !important;
}
.post-content h3, #cnblogs_post_body h3 {
  font-size: 1.3em !important; font-weight: 700 !important;
  color: #34495e !important;
  border-bottom: 2px solid #4a90d9 !important;
  padding-bottom: 4px !important; margin: 20px 0 12px !important;
}
.post-content h4, #cnblogs_post_body h4 {
  font-size: 1.15em !important; font-weight: 700 !important;
  color: #4a90d9 !important; padding-left: 10px !important;
  border-left: 3px solid #4a90d9 !important; margin: 18px 0 10px !important;
}
.post-content h5, #cnblogs_post_body h5 {
  font-size: 1em !important; font-weight: 700 !important;
  color: #2c3e50 !important; margin: 14px 0 8px !important;
  padding: 0 !important; border: none !important;
}

body.dark-mode .post-content h1, body.dark-mode #cnblogs_post_body h1,
body.dark-mode .post-content h2, body.dark-mode #cnblogs_post_body h2,
body.dark-mode .post-content h3, body.dark-mode #cnblogs_post_body h3,
body.dark-mode .post-content h5, body.dark-mode #cnblogs_post_body h5 {
  color: #e5e7eb !important;
}
body.dark-mode .post-content h4, body.dark-mode #cnblogs_post_body h4 { color: #60a5fa !important; }
body.dark-mode .post-content h2, body.dark-mode #cnblogs_post_body h2 {
  background: linear-gradient(to right, rgba(96,165,250,0.12), transparent) !important;
}

.post-content strong, #cnblogs_post_body strong {
  color: #c0392b !important; font-weight: 700 !important;
}
body.dark-mode .post-content strong, body.dark-mode #cnblogs_post_body strong {
  color: #f472b6 !important;
}
.post-content hr, #cnblogs_post_body hr {
  border: none !important; height: 1px !important;
  background: linear-gradient(to right, transparent, #c5d0dc, transparent) !important;
  margin: 24px 0 !important;
}
body.dark-mode .post-content hr, body.dark-mode #cnblogs_post_body hr {
  background: linear-gradient(to right, transparent, #4b5563, transparent) !important;
}
.post-content a:not(.code-copy-btn),
#cnblogs_post_body a:not(.code-copy-btn) {
  color: #4a90d9 !important; text-decoration: none !important;
  background-image: linear-gradient(to right, #4a90d9, #4a90d9) !important;
  background-size: 0% 1px !important;
  background-repeat: no-repeat !important;
  background-position: 0 100% !important;
  transition: background-size 0.3s !important;
}
.post-content a:not(.code-copy-btn):hover,
#cnblogs_post_body a:not(.code-copy-btn):hover {
  background-size: 100% 1px !important;
}

/* ================================================
   11. 夜间模式
   ================================================ */
body.dark-mode { background: #111827 !important; color: #d1d5db !important; }
body.dark-mode #home, body.dark-mode #body, body.dark-mode .forFlow { background: #111827 !important; }
body.dark-mode .post-item, body.dark-mode #topics,
body.dark-mode .post-content, body.dark-mode #cnblogs_post_body {
  background: #1f2937 !important; color: #d1d5db !important;
}
body.dark-mode #sideBar, body.dark-mode .sidebar-block, body.dark-mode #sideBarMain {
  background: #1f2937 !important; color: #9ca3af !important;
}
body.dark-mode a { color: #60a5fa !important; }
body.dark-mode .post-content blockquote, body.dark-mode #cnblogs_post_body blockquote {
  background: linear-gradient(to right,#1e3a5f,#1a2e4a) !important;
  color: #93c5fd !important; border-left-color: #3b82f6 !important;
}
body.dark-mode .post-content table th, body.dark-mode #cnblogs_post_body table th {
  background: #374151 !important; color: #f9fafb !important; border-color: #4b5563 !important;
}
body.dark-mode .post-content table td, body.dark-mode #cnblogs_post_body table td {
  border-color: #374151 !important; color: #d1d5db !important;
}
body.dark-mode .post-content table tr:nth-child(even),
body.dark-mode #cnblogs_post_body table tr:nth-child(even) { background: #1f2937 !important; }

/* ================================================
   12. 键盘快捷键模态框
   ================================================ */
#shortcuts-modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 999995;
  align-items: center; justify-content: center;
  animation: fadeIn 0.2s;
}
#shortcuts-modal.show { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.shortcuts-content {
  background: #fff; border-radius: 12px;
  padding: 24px 30px; min-width: 360px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: popIn 0.2s;
}
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
body.dark-mode .shortcuts-content { background: #1f2937; color: #d1d5db; }
.shortcuts-content h3 {
  margin: 0 0 14px !important; font-size: 16px !important;
  border-bottom: 2px solid #4a90d9 !important; padding-bottom: 6px !important;
  color: #2c3e50 !important;
}
body.dark-mode .shortcuts-content h3 { color: #93c5fd !important; }
.shortcuts-content ul { list-style: none; padding: 0; margin: 0; }
.shortcuts-content li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px dashed #e5e7eb; font-size: 13px;
}
body.dark-mode .shortcuts-content li { border-bottom-color: #374151; }
.shortcuts-content li:last-child { border-bottom: none; }
.shortcuts-content kbd {
  background: #f3f4f6; border: 1px solid #d1d5db;
  border-radius: 4px; padding: 2px 8px; font-family: monospace;
  font-size: 12px; color: #333; box-shadow: 0 1px 0 rgba(0,0,0,0.1);
  margin: 0 2px;
}
body.dark-mode .shortcuts-content kbd {
  background: #374151; border-color: #4b5563; color: #e5e7eb;
}

/* ================================================
   15. 点击彩蛋
   ================================================ */
.click-tip {
  position: absolute;
  background: linear-gradient(135deg, #ff6b9d, #7c3aed, #4a90d9);
  color: #fff;
  padding: 6px 14px;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: all 1.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 99996;
  box-shadow: 0 4px 16px rgba(124,58,237,0.35);
  white-space: nowrap;
  user-select: none;
  letter-spacing: 0.3px;
}
.click-tip.show {
  opacity: 1;
  transform: translate(-50%, calc(-50% - 40px));
}
.click-tip.fade {
  opacity: 0;
  transform: translate(-50%, calc(-50% - 80px));
}

/* ================================================
   16. 时段问候横幅
   ================================================ */
#greeting-banner {
  position: fixed;
  top: 60px; left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: linear-gradient(135deg, rgba(74,144,217,0.95), rgba(124,58,237,0.95));
  color: #fff;
  padding: 10px 24px;
  border-radius: 22px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  box-shadow: 0 6px 24px rgba(74,144,217,0.35);
  backdrop-filter: blur(8px);
  z-index: 99994;
  opacity: 0;
  transition: opacity 0.5s, transform 0.5s;
  pointer-events: none;
  display: flex; align-items: center; gap: 8px;
}
#greeting-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ================================================
   17. 读完全文庆祝卡片
   ================================================ */
#completion-card {
  position: fixed;
  bottom: 30px; right: 30px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  padding: 14px 22px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(239,68,68,0.4);
  z-index: 99993;
  opacity: 0;
  transform: translateY(30px) scale(0.9);
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex; align-items: center; gap: 10px;
  max-width: 280px;
  pointer-events: none;
}
#completion-card.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#completion-card .cc-icon { font-size: 24px; }
#completion-card .cc-close {
  background: rgba(255,255,255,0.25); border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; margin-left: 4px;
  transition: background 0.2s;
}
#completion-card .cc-close:hover { background: rgba(255,255,255,0.45); }

/* ================================================
   13. 移动端
   ================================================ */
@media (max-width: 768px) {
  #header { min-height: 180px !important; padding-top: 46px !important; }
  body.is-post #header { min-height: 220px !important; }
  #blogTitle { padding: 6px 20px 4px !important; }
  #blogTitle a { font-size: 18px !important; }
  #header-nav-inject { padding: 4px 14px !important; gap: 1px !important; }
  #header-nav-inject a { font-size: 11px !important; padding: 4px 8px !important; }
  #post-hero-inner { padding: 0 16px 20px !important; }
  #post-hero-inner h1 { font-size: 16px !important; }
  .hero-meta { gap: 10px !important; font-size: 11px !important; }

  #right-toolbar { right: 8px !important; gap: 5px !important; }
  .rt-btn { width: 34px !important; height: 34px !important; font-size: 14px !important; }
  #rt-home, #rt-like, #rt-fav, #rt-share, #rt-font-plus, #rt-font-minus, #rt-comments, #rt-print { display: none !important; }

  #toc-panel { right: 50px !important; width: 200px !important; font-size: 12px !important; }
  .post-content img, #cnblogs_post_body img { width: 96% !important; }
  .shortcuts-content { min-width: 90vw !important; padding: 18px 20px !important; }
  #completion-card { right: 12px !important; bottom: 12px !important; max-width: calc(100vw - 24px) !important; }
}

/* ================================================
   14. 打印
   ================================================ */
@media print {
  #custom-topbar, #custom-drawer, #custom-drawer-overlay,
  #right-toolbar, #toc-panel, #read-progress,
  #sideBar, #header-nav-inject, #footer, #shortcuts-modal,
  #reading-resume-toast, .code-copy-btn, #img-lightbox,
  #greeting-banner, #completion-card, .click-tip {
    display: none !important;
  }
  #header { min-height: auto !important; background: #fff !important; }
  #header::before { display: none !important; }
  #post-hero-inner h1 { color: #000 !important; text-shadow: none !important; }
  .hero-meta { color: #555 !important; }
  .hero-badge { background: #eee !important; color: #333 !important; border: 1px solid #ccc !important; }
  .post-content, #cnblogs_post_body { background: #fff !important; color: #000 !important; }
  .post-content pre, #cnblogs_post_body pre {
    background: #f5f5f5 !important; border: 1px solid #ccc !important;
    page-break-inside: avoid;
  }
  .post-content img, #cnblogs_post_body img {
    page-break-inside: avoid; max-width: 100% !important;
    box-shadow: none !important; border: 1px solid #ccc;
  }
  .post-content h1, .post-content h2, .post-content h3,
  #cnblogs_post_body h1, #cnblogs_post_body h2, #cnblogs_post_body h3 {
    page-break-after: avoid; color: #000 !important;
  }
  a { color: #000 !important; text-decoration: underline !important; }
}