/* ===========================================
   🖥️ PROGRAMMER THEME - 程序员风格主题 (修复版)
   =========================================== */

/* ===== 全局基础样式 ===== */
:root {
  /* 🎨 程序员风格配色方案 */
  --primary: #007acc;
  --primary-hover: #005a99;
  --secondary: #666666;
  --accent: #e91e63;
  --success: #28a745;
  --warning: #ffc107;
  --error: #dc3545;

  /* 📝 亮色主题背景色系 */
  --bg-primary: #ffffff;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f8f9fa;
  --bg-card: #ffffff;
  --bg-hover: #f8f9fa;

  /* 📝 亮色主题文字颜色 */
  --text-primary: #000000;
  --text-secondary: #000000;
  --text-muted: #333333;
  --text-link: #0066cc;
  --text-code: #e91e63;

  /* 🔲 亮色主题边框和分割线 */
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --divider: #e0e0e0;

  /* 📦 亮色主题组件背景 */
  --card-bg: #ffffff;
  --entry-bg: #ffffff;
  --code-bg: #ffffff;
  --tooltip-bg: #333333;

  /* 🔤 字体配置 - 使用本地字体 */
  --font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-family-heading: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-family-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;

  /* 📏 间距系统 */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;

  /* 🔘 圆角系统 */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* 🎯 阴影系统 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* ===== 深色主题支持 ===== */
[data-theme="dark"], .dark {
  /* 📝 深色主题背景色系 */
  --bg-primary: #1e1e1e;
  --bg-secondary: #252526;
  --bg-tertiary: #2d2d30;
  --bg-card: #1e1e1e;
  --bg-hover: #37373d;

  /* 📝 深色主题文字颜色 */
  --text-primary: #cccccc;
  --text-secondary: #8c8c8c;
  --text-muted: #6c6c6c;
  --text-link: #4fc3f7;
  --text-code: #dcdcaa;

  /* 🔲 深色主题边框和分割线 */
  --border: #3e3e42;
  --border-light: #454545;
  --divider: #3e3e42;

  /* 📦 深色主题组件背景 */
  --card-bg: #1e1e1e;
  --entry-bg: #252526;
  --code-bg: #1e1e1e;
  --tooltip-bg: #2d2d30;

  /* 📏 深色主题阴影系统 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

/* ===== 亮色主题优化 ===== */
body {
  background-color: #ffffff !important;
  color: var(--text-primary);
}

/* 确保主要内容区域使用白色背景 */
.main, .content, .post-content, .list {
  background-color: #ffffff !important;
  color: var(--text-primary);
}

/* 确保所有容器都使用白色背景 */
.container, .page-single, .post-single, .entry {
  background-color: #ffffff !important;
}

/* 确保头部和底部也使用白色背景 */
.header, .footer, .nav {
  background-color: #ffffff !important;
}

/* 确保卡片和组件使用白色背景 */
.post-card, .card, .entry-content {
  background-color: #ffffff !important;
}

/* 标题颜色优化 */
h1, h2, h3, h4, h5, h6 {
  color: #000000 !important;
  font-weight: 600;
}

/* 链接颜色优化 */
a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* 代码块优化 */
code, pre {
  font-family: ui-monospace, "JetBrains Mono", SFMono-Regular, Consolas, monospace;
}

code {
  background-color: var(--code-bg);
  color: var(--text-code);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

/* 引用块优化 */
blockquote {
  border-left: 4px solid var(--primary);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 1rem;
  margin: 1rem 0;
}

/* 表格优化 */
table {
  border-collapse: collapse;
  width: 100%;
  background-color: var(--bg-primary);
}

table th,
table td {
  border: 1px solid var(--border);
  padding: 0.75rem;
  text-align: left;
}

table th {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
}

/* 按钮优化 */
.btn, button {
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn:hover, button:hover {
  background-color: var(--primary-hover);
}

/* 卡片组件优化 */
.card, .post-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== 深色模式优化 ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333333;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --border: #404040;
  }
}

/* ===== 基础样式重置 ===== */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== 容器和布局 ===== */
.container, .page-single {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--spacing-lg);
}

/* 主要内容区域优化 */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

/* 文章页面布局优化 */
.post-single {
  max-width: none;
  width: 100%;
  margin: 0;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* ===== 头部样式 ===== */
.post-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

.post-title {
  font-family: var(--font-family-heading);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  letter-spacing: -0.025em;
}

.post-description {
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: var(--spacing-lg);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  align-items: center;
  font-size: 0.85rem;
  color: #666666 !important;
  opacity: 0.65;
  margin-bottom: 1.5rem;
}

.post-meta * {
  color: #666666 !important;
  font-size: inherit;
}

.post-meta-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

/* ===== 文章内容 ===== */
.post-content {
  font-size: 17px;
  line-height: 1.8;
  color: #000000 !important;
  max-width: 72ch;
  width: 100%;
  margin-inline: auto;
  overflow-x: auto;
  font-family: 'Inter', 'Source Sans 3', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  padding: 2rem 1.5rem;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  font-family: 'Inter', 'Source Sans 3', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  color: #000000 !important;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.post-content h1 {
  font-size: 2rem;
  border-bottom: 2px solid var(--primary);
  padding-bottom: var(--spacing-sm);
}

.post-content h2 {
  font-size: 1.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--spacing-xs);
  margin: 2.4em 0 1em;
}

.post-content h3 { 
  font-size: 1.5rem; 
  margin: 2em 0 0.8em;
}
.post-content h4 { 
  font-size: 1.25rem; 
  margin: 1.6em 0 0.6em;
}
.post-content h5 { 
  font-size: 1.1rem; 
  margin: 1.6em 0 0.6em;
}
.post-content h6 { 
  font-size: 1rem; 
  margin: 1.6em 0 0.6em;
}

.post-content p {
  margin-bottom: 1.5rem;
  text-align: left;
  color: #2c3e50 !important;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.post-content p:first-of-type {
  font-size: 1.1em;
  color: #34495e !important;
  margin-bottom: 2rem;
}

.post-content p:first-of-type::first-letter {
  font-size: 3.2em;
  font-weight: 700;
  line-height: 1;
  float: left;
  margin: 0.1em 0.1em 0 0;
  color: var(--primary);
}

.post-content blockquote {
  border-left: 4px solid var(--primary);
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 1.5rem 2rem;
  margin: 2rem 0;
  border-radius: 12px;
  font-style: italic;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  font-family: 'Inter', 'Source Sans 3', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
}

.post-content blockquote::before {
  content: '"';
  font-size: 4rem;
  color: var(--primary);
  position: absolute;
  top: -0.5rem;
  left: 1rem;
  font-family: Georgia, serif;
  opacity: 0.3;
}

.post-content blockquote p {
  margin-bottom: 0;
  color: #495057 !important;
  font-size: 1.1em;
  line-height: 1.7;
}

.post-content ul,
.post-content ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
}

.post-content ul {
  list-style: none;
}

.post-content ul li {
  position: relative;
  margin-bottom: 0.8rem;
  color: #2c3e50 !important;
  padding-left: 1.5rem;
}

.post-content ul li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: bold;
}

.post-content ol li {
  margin-bottom: 0.8rem;
  color: #2c3e50 !important;
  padding-left: 0.5rem;
}

.post-content ol {
  counter-reset: item;
}

.post-content ol li::marker {
  color: var(--primary);
  font-weight: bold;
}

.post-content a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.3s ease;
  font-weight: 500;
  position: relative;
}

.post-content a:hover {
  color: var(--primary-hover);
  border-bottom-color: var(--primary-hover);
}

.post-content a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -2px;
  left: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  transition: width 0.3s ease;
}

.post-content a:hover::after {
  width: 100%;
}

/* ===== 代码块样式 ===== */
.post-content pre {
  background: #ffffff !important;
  border: 1px solid #e0e0e0 !important;
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin: var(--spacing-xl) 0;
  overflow-x: auto;
  font-family: ui-monospace, "JetBrains Mono", SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
  width: 100%;
  max-width: none;
}

/* 代码复制按钮样式已移除 */

.post-content code {
  background: #ffffff !important;
  color: var(--text-code);
  padding: 2px 6px;
  border: 1px solid #e0e0e0 !important;
  border-radius: var(--radius-sm);
  font-family: var(--font-family-mono);
  font-size: 0.9em;
}

.post-content pre code {
  background: transparent !important;
  border: none !important;
  padding: 0;
  border-radius: 0;
}

/* ===== Callout 样式 ===== */
.callout {
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
  border: 1px solid var(--c-br);
  background: var(--c-bg);
}

.callout.why {
  --c-bg: #f5faff;
  --c-br: #d6e8ff;
}

.callout.order {
  --c-bg: #f9fff5;
  --c-br: #e3f6d5;
}

.callout.branch {
  --c-bg: #fff8f5;
  --c-br: #ffe3d6;
}

.callout h4 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

/* ===== 折叠区域样式 ===== */
.collapsible {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin: 1rem 0;
  overflow: hidden;
}

.collapsible-header {
  background: #f8f9fa;
  padding: 1rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  transition: background-color 0.2s ease;
}

.collapsible-header:hover {
  background: #e9ecef;
}

.collapsible-icon {
  transition: transform 0.2s ease;
}

.collapsible.open .collapsible-icon {
  transform: rotate(90deg);
}

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.collapsible.open .collapsible-content {
  max-height: 2000px;
}

.collapsible-body {
  padding: 1rem;
}

/* ===== 双栏布局 ===== */
.figure-code {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
  margin: 2rem 0;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.figure-code .code-section {
  background: #f8f9fa;
}

.figure-code .notes-section {
  background: #ffffff;
  padding: 1rem;
}

.figure-code .notes-section .callout {
  margin: 0.5rem 0;
}

@media (max-width: 1024px) {
  .figure-code {
    grid-template-columns: 1fr;
  }
  
  .figure-code .code-section {
    order: 1;
  }
  
  .figure-code .notes-section {
    order: 2;
  }
}

/* ===== 文章美化元素 ===== */
.post-content hr {
  border: none;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  margin: 3rem 0;
  border-radius: 2px;
}

.post-content strong {
  color: #2c3e50;
  font-weight: 600;
  background: linear-gradient(120deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 0.1em 0.3em;
  border-radius: 4px;
}

.post-content em {
  color: var(--primary);
  font-style: italic;
  position: relative;
}

.post-content mark {
  background: linear-gradient(120deg, #fff3cd 0%, #ffeaa7 100%);
  padding: 0.1em 0.3em;
  border-radius: 4px;
  color: #856404;
}

/* 段落间距优化 */
.post-content > *:first-child {
  margin-top: 0;
}

.post-content > *:last-child {
  margin-bottom: 0;
}

/* ===== 增强版文章阅读进度条 ===== */
.reading-progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  z-index: 9999;
  opacity: 0;
  transform: translateY(-100%);
  transition: all 0.3s ease;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.reading-progress-container.visible {
  opacity: 1;
  transform: translateY(0);
}

.reading-progress-container.hover {
  height: 8px;
  box-shadow: 0 2px 12px rgba(0, 122, 204, 0.3);
}

.reading-progress-container.active {
  animation: progressPulse 2s ease-in-out infinite;
}

.reading-progress-container.completed {
  animation: progressComplete 1s ease-in-out;
}

.reading-progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57);
  background-size: 500% 100%;
  animation: progressGradient 3s ease infinite;
  transition: width 0.2s ease;
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 10px rgba(0, 122, 204, 0.5);
}

.reading-progress-indicator {
  position: absolute;
  top: -2px;
  left: 0%;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 2px solid var(--primary);
  border-radius: 50%;
  transform: translateX(-50%);
  transition: left 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.reading-progress-container.hover .reading-progress-indicator {
  width: 12px;
  height: 12px;
  top: -3px;
}

.reading-progress-text {
  position: absolute;
  top: 12px;
  right: 20px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.reading-progress-container.hover .reading-progress-text {
  opacity: 1;
  transform: translateY(0);
}

.reading-time-estimate {
  position: absolute;
  top: 12px;
  left: 20px;
  background: rgba(0, 122, 204, 0.9);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.reading-progress-container.hover .reading-time-estimate {
  opacity: 1;
  transform: translateY(0);
}

.current-chapter-info {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(10px);
  animation: chapterInfoSlide 0.3s ease-out;
  z-index: 1;
}

@keyframes chapterInfoSlide {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* 庆祝粒子效果 */
.reading-particle {
  position: absolute;
  top: -20px;
  font-size: 16px;
  pointer-events: none;
  animation: particleFloat 2s ease-out forwards;
  z-index: 10;
}

/* 动画效果 */
@keyframes progressPulse {
  0%, 100% {
    box-shadow: 0 0 5px rgba(0, 122, 204, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(0, 122, 204, 0.6);
  }
}

@keyframes progressComplete {
  0% {
    background: rgba(0, 0, 0, 0.1);
  }
  50% {
    background: rgba(76, 175, 80, 0.3);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
  }
  100% {
    background: rgba(0, 0, 0, 0.1);
  }
}

@keyframes progressGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes particleFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-50px) scale(0.5);
  }
}

/* 滚动方向效果 */
.reading-progress-container.scrolling-down {
  opacity: 0.7;
}

.reading-progress-container.scrolling-up {
  opacity: 1;
}

/* 移动端优化 */
@media (max-width: 768px) {
  .reading-progress-container {
    height: 4px;
  }
  
  .reading-progress-container.hover {
    height: 6px;
  }
  
  .reading-progress-text,
  .reading-time-estimate {
    font-size: 0.7rem;
    padding: 3px 6px;
    top: 8px;
  }
  
  .reading-progress-text {
    right: 10px;
  }
  
  .reading-time-estimate {
    left: 10px;
  }
  
  .reading-progress-indicator {
    width: 8px;
    height: 8px;
    top: -2px;
  }
  
  .reading-progress-container.hover .reading-progress-indicator {
    width: 10px;
    height: 10px;
  }
}

/* ===== 表格样式 ===== */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--spacing-xl) 0;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.post-content th,
.post-content td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.post-content th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
  border-bottom: 2px solid var(--primary);
}

.post-content tr:hover {
  background: var(--bg-tertiary);
}

/* ===== 图片样式 ===== */
.post-content img {
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin: var(--spacing-lg) auto;
  display: block;
  cursor: zoom-in;
  transition: all 0.3s ease;
  border: 1px solid #e0e0e0;
}

.post-content img:hover {
  box-shadow: var(--shadow-lg);
  transform: scale(1.02);
}

/* 图片放大模态框 */
.image-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(5px);
}

.image-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  cursor: zoom-out;
  border: none;
  margin: 0;
}

.image-modal img:hover {
  transform: none;
}

.image-modal .close-btn {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.image-modal .close-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* 图片信息栏 */
.image-info {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  backdrop-filter: blur(10px);
}

/* 确保图片容器不会限制图片显示 */
.post-content figure,
.post-content .image-container {
  max-width: none !important;
  width: 100%;
  text-align: center;
  margin: var(--spacing-lg) 0;
  overflow: visible;
}

.post-content figure img {
  margin: 0 auto;
}

/* 图片标题样式 */
.post-content figcaption,
.image-caption {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: var(--spacing-sm);
  font-style: italic;
  padding: 0 1rem;
}

/* SVG图片特殊处理 */
.post-content svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  cursor: default;
}

/* 小图片样式 */
.post-content img[width*="small"],
.post-content img.small {
  max-width: 300px;
  cursor: zoom-in;
}

/* 中等图片样式 */
.post-content img[width*="medium"],
.post-content img.medium {
  max-width: 500px;
  cursor: zoom-in;
}

/* 大图片样式 */
.post-content img[width*="large"],
.post-content img.large {
  max-width: 800px;
  cursor: zoom-in;
}

/* 全宽图片样式 */
.post-content img[width*="full"],
.post-content img.full {
  max-width: 100%;
  width: 100%;
  cursor: zoom-in;
}

.post-content .image-caption {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: var(--spacing-sm);
  font-style: italic;
}

/* ===== 按钮和链接 ===== */
.btn, button, .button {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--primary);
  color: var(--bg-primary);
  text-decoration: none;
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover, button:hover, .button:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}

/* ===== 卡片组件 ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin: var(--spacing-lg) 0;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.card-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.card-title {
  font-family: var(--font-family-heading);
  font-size: 1.5rem;
  color: var(--primary);
  margin: 0;
}

.card-content {
  color: var(--text-primary);
}

/* ===== 标签和徽章 ===== */
.tag, .badge {
  display: inline-flex;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-family-mono);
  border: 1px solid var(--border);
}

.tag:hover, .badge:hover {
  background: var(--primary);
  color: var(--bg-primary);
  border-color: var(--primary);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin: var(--spacing-md) 0;
}

/* ===== 面包屑优化 ===== */
.breadcrumbs {
  font-size: 0.8rem;
  color: #666666;
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

.breadcrumbs a {
  color: #666666;
  text-decoration: none;
  padding: 0.2rem 0.4rem;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.breadcrumbs a:hover {
  background: #f0f0f0;
  color: var(--primary);
}

.breadcrumbs .separator {
  margin: 0 0.25rem;
  opacity: 0.5;
}

/* ===== 导航和菜单 ===== */
.nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: var(--spacing-md) 0;
}

.nav-list {
  display: flex;
  gap: var(--spacing-lg);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item a {
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-family);
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-item a:hover,
.nav-item a.active {
  color: var(--primary);
}

/* ===== 页脚 ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: var(--spacing-xl) 0;
  margin-top: var(--spacing-2xl);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
}

.footer a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ===== 响应式设计 ===== */
/* 大屏幕优化 */
@media (min-width: 1600px) {
  .main {
    max-width: 1600px;
    padding: 0 var(--spacing-xl);
  }
  
  .container, .page-single {
    max-width: 1600px;
  }
}

/* 超大屏幕优化 */
@media (min-width: 1920px) {
  .main {
    max-width: 1800px;
    padding: 0 var(--spacing-2xl);
  }
  
  .container, .page-single {
    max-width: 1800px;
  }
}

/* 平板和小屏幕 */
/* 回到顶部按钮样式已移除，使用PaperMod主题内置样式 */

/* ===== 标题锚点 ===== */
.post-content h2:hover .anchor,
.post-content h3:hover .anchor {
  opacity: 1;
}

.anchor {
  opacity: 0;
  margin-left: 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.anchor:hover {
  color: var(--primary);
}

/* ===== 增强版粘性目录 (ToC) - 跟随视窗移动 ===== */
.toc-container {
  position: fixed !important;
  top: 50% !important;
  right: 2rem !important;
  transform: translateY(-50%) !important;
  max-width: 300px;
  min-width: 260px;
  max-height: 75vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  z-index: 100;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  /* 确保始终跟随视窗 */
  left: auto !important;
}

.toc-container:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  transform: translateY(-50%) scale(1.02);
}

/* 目录跳转指示器 */
.toc-container::after {
  content: '📍 点击跳转到章节';
  position: absolute;
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 15px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 101;
}

.toc-container:hover::after {
  opacity: 1;
}

.toc-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.toc-title span {
  font-size: 1.1rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item {
  margin: 0.125rem 0;
  position: relative;
}

.toc-item.active {
  background: linear-gradient(90deg, rgba(0, 122, 204, 0.15), rgba(0, 122, 204, 0.05));
  border-radius: 8px;
  position: relative;
  animation: tocItemPulse 2s ease-in-out infinite;
}

.toc-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background: linear-gradient(180deg, var(--primary), #0056b3);
  border-radius: 0 2px 2px 0;
  animation: activeIndicator 0.3s ease-out;
}

.toc-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 8px;
  transition: all 0.25s ease;
  position: relative;
  line-height: 1.4;
  font-weight: 500;
  transform-origin: left center;
}

.toc-indicator {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-secondary);
  margin-right: 0.75rem;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.toc-link:hover {
  background: var(--bg-tertiary);
  color: var(--primary);
  transform: translateX(4px);
  padding-left: 1rem;
}

.toc-link:hover .toc-indicator {
  background: var(--primary);
  transform: scale(1.5);
}

.toc-link.active {
  background: linear-gradient(135deg, var(--primary), #0056b3);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 122, 204, 0.3);
}

.toc-link.active .toc-indicator {
  background: white;
  transform: scale(1.2);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.toc-link.clicking {
  transform: scale(0.95);
  background: var(--primary);
  color: white;
}

/* 不同级别的标题样式 */
.toc-item.level-h1 .toc-link {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
}

.toc-item.level-h1 .toc-indicator {
  width: 6px;
  height: 6px;
  background: var(--primary);
}

.toc-item.level-h2 .toc-link {
  font-weight: 600;
  font-size: 0.875rem;
}

.toc-item.level-h3 .toc-link {
  padding-left: 1.5rem;
  font-size: 0.825rem;
  font-weight: 500;
}

.toc-item.level-h3 .toc-indicator {
  width: 3px;
  height: 3px;
}

.toc-item.level-h4 .toc-link {
  padding-left: 2.25rem;
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.8;
}

.toc-item.level-h4 .toc-indicator {
  width: 2px;
  height: 2px;
}

/* 目标高亮效果 */
.highlight-target {
  background: linear-gradient(90deg, rgba(0, 122, 204, 0.15), rgba(0, 122, 204, 0.05));
  border-left: 4px solid var(--primary);
  padding-left: 1rem;
  margin-left: -1rem;
  border-radius: 8px;
  animation: highlightPulse 3s ease-out;
  position: relative;
  overflow: hidden;
}

.highlight-target::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 122, 204, 0.2), transparent);
  animation: highlightSweep 1s ease-out;
}

@keyframes highlightPulse {
  0% { 
    background: rgba(0, 122, 204, 0.3);
    transform: scale(1.02);
  }
  50% { 
    background: rgba(0, 122, 204, 0.2);
  }
  100% { 
    background: rgba(0, 122, 204, 0.05);
    transform: scale(1);
  }
}

@keyframes highlightSweep {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* 滚动条样式 */
.toc-container::-webkit-scrollbar {
  width: 4px;
}

.toc-container::-webkit-scrollbar-track {
  background: transparent;
}

.toc-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.toc-container::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ToC 高亮动画效果 */
@keyframes tocItemPulse {
  0%, 100% {
    background: linear-gradient(90deg, rgba(0, 122, 204, 0.15), rgba(0, 122, 204, 0.05));
  }
  50% {
    background: linear-gradient(90deg, rgba(0, 122, 204, 0.25), rgba(0, 122, 204, 0.1));
  }
}

@keyframes activeIndicator {
  0% {
    width: 0;
    opacity: 0;
  }
  100% {
    width: 4px;
    opacity: 1;
  }
}

/* 增强的活动链接样式 */
.toc-link.active {
  background: linear-gradient(135deg, var(--primary), #0056b3);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 122, 204, 0.3);
  transform: translateX(4px);
}

.toc-link.active .toc-indicator {
  background: white;
  transform: scale(1.3);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* 阅读进度同步效果 */
.toc-item.reading {
  background: linear-gradient(90deg, rgba(255, 193, 7, 0.1), transparent);
}

.toc-item.reading .toc-link {
  color: #ff9800;
}

.toc-item.reading .toc-indicator {
  background: #ff9800;
  animation: readingPulse 1.5s ease-in-out infinite;
}

@keyframes readingPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }
}

/* 层级视觉增强 */
.toc-item.level-h1.active::before {
  height: 80%;
  width: 5px;
}

.toc-item.level-h2.active::before {
  height: 60%;
  width: 4px;
}

.toc-item.level-h3.active::before {
  height: 40%;
  width: 3px;
  left: 1rem;
}

.toc-item.level-h4.active::before {
  height: 30%;
  width: 2px;
  left: 1.75rem;
}

/* ===== 移动端优化 ===== */
@media (max-width: 768px) {
  .toc-container {
    display: none;
  }
}

/* ===== 平板端优化 - 跟随视窗移动 ===== */
@media (min-width: 769px) and (max-width: 1023px) {
  .toc-container {
    display: block !important;
    position: fixed !important;
    top: 50% !important;
    right: 1rem !important;
    transform: translateY(-50%) !important;
    max-width: 240px;
    min-width: 200px;
    z-index: 100;
    /* 确保始终跟随视窗 */
    left: auto !important;
  }
}
  
  .main {
    padding: 0 var(--spacing-md);
  }
  
  .container, .page-single {
    padding: var(--spacing-md);
  }

  /* 移动端图片优化 */
  .post-content img {
    max-width: 100%;
    width: 100%;
    height: auto;
    margin: 1rem 0;
    border-radius: 6px;
  }

  .post-content img:hover {
    transform: none;
  }

  .image-modal .close-btn {
    top: 10px;
    right: 15px;
    width: 40px;
    height: 40px;
    font-size: 30px;
  }

  .image-info {
    bottom: 10px;
    padding: 8px 16px;
    font-size: 12px;
    max-width: 90%;
  }

  /* 小屏幕下的图片尺寸类 */
  .post-content img.small,
  .post-content img.medium,
  .post-content img.large {
    max-width: 100%;
  }

  /* 移动端文章内容优化 */
  .post-content {
    font-size: 16px;
    line-height: 1.7;
    padding: 1.5rem 1rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    max-width: 100%;
  }

  .post-content h1,
  .post-content h2,
  .post-content h3,
  .post-content h4,
  .post-content h5,
  .post-content h6 {
    line-height: 1.3;
  }

  .post-content h2 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
  }

  .post-content h3 {
    font-size: 1.3rem;
    margin: 1.5rem 0 0.8rem;
  }

  .post-content p {
    margin-bottom: 1.2rem;
  }

  .post-content p:first-of-type::first-letter {
    font-size: 2.5em;
    margin: 0.05em 0.08em 0 0;
  }

  .post-content blockquote {
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    font-size: 1rem;
  }

  .post-content blockquote::before {
    font-size: 3rem;
    top: -0.3rem;
    left: 0.5rem;
  }

  .post-content ul li,
  .post-content ol li {
    margin-bottom: 0.6rem;
    font-size: 0.95em;
  }

  .post-content ul li {
    padding-left: 1rem;
  }

  .post-content a {
    word-break: break-word;
  }

  /* 移动端表格优化 */
  .post-content table {
    font-size: 0.9rem;
    margin: 1rem 0;
  }

  .post-content th,
  .post-content td {
    padding: 0.5rem;
  }

  /* 移动端代码块优化 */
  .post-content pre {
    font-size: 0.85rem;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
  }

  .post-content code {
    font-size: 0.9em;
    padding: 0.2em 0.4em;
  }

  /* 移动端美化元素优化 */
  .post-content strong {
    padding: 0.05em 0.2em;
  }

  .post-content mark {
    padding: 0.05em 0.2em;
  }

  .post-content hr {
    margin: 2rem 0;
  }
}

  .post-title {
    font-size: 2rem;
  }

  .post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-xs);
  }

  .nav-list {
    flex-direction: column;
    gap: var(--spacing-md);
  }

  .post-content pre {
    font-size: 0.8rem;
    padding: var(--spacing-md);
  }
}

/* ===== 动画效果 ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

/* ===== 滚动条样式 ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ===== 选择和焦点样式 ===== */
::selection {
  background: var(--primary);
  color: var(--bg-primary);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== 程序员特色样式 ===== */
.chroma {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.chroma .ln {
  color: var(--text-muted);
  user-select: none;
}

/* ===== 终端风格组件 ===== */
.terminal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  font-family: var(--font-family-mono);
  font-size: 0.9rem;
  overflow-x: auto;
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border);
}

.terminal-button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-button.red { background: var(--error); }
.terminal-button.yellow { background: var(--warning); }
.terminal-button.green { background: var(--success); }

.terminal-prompt {
  color: var(--primary);
  font-weight: bold;
}

.terminal-output {
  color: var(--text-primary);
  line-height: 1.5;
}

/* ===== 数据展示 ===== */
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-lg);
  margin: var(--spacing-xl) 0;
}

.data-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  text-align: center;
}

.data-value {
  font-family: var(--font-family-heading);
  font-size: 2rem;
  color: var(--primary);
  font-weight: bold;
}

.data-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: var(--spacing-sm);
}

/* ===== 程序员风格的注释 ===== */
.comment {
  color: var(--text-secondary);
  font-style: italic;
  border-left: 3px solid var(--accent);
  padding-left: var(--spacing-md);
  margin: var(--spacing-lg) 0;
  background: var(--bg-secondary);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
}

/* ===== 渐变效果 ===== */
.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== 程序员主题标识 ===== */
.programmer-theme-applied {
  font-family: var(--font-family) !important;
}

.programmer-theme-applied * {
  transition: all 0.2s ease;
}

/* ===== 确保主题正确应用 ===== */
@media (prefers-color-scheme: dark) {
  .programmer-theme-applied {
    background-color: var(--bg-primary);
    color: var(--text-primary);
  }
}

/* ===== 文章导航按钮优化 ===== */
.paginav {
  margin: 2rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: 'Inter', 'Source Sans 3', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
}

.paginav a {
  flex: 1;
  max-width: 48%;
  padding: 0.75rem 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  text-decoration: none;
  color: #333333;
  background: #ffffff;
  transition: all 0.2s ease;
  display: block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.paginav a:hover {
  border-color: #007acc;
  box-shadow: 0 2px 8px rgba(0, 122, 204, 0.15);
  transform: translateY(-1px);
}

.paginav .prev {
  text-align: left;
}

.paginav .next {
  text-align: right;
}

.paginav .title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #007acc;
  display: block;
  margin-bottom: 0.25rem;
}

.paginav span:not(.title) {
  font-size: 0.9rem;
  color: #666666;
  line-height: 1.4;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 移动端优化 */
@media (max-width: 768px) {
  .paginav {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .paginav a {
    max-width: 100%;
    padding: 0.875rem 1rem;
  }
  
  .paginav .prev,
  .paginav .next {
    text-align: center;
  }
  
  .paginav span:not(.title) {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }
}