.article-detail { max-width: 800px; margin: 0 auto; }
.article-header { margin-bottom: 32px; }
.article-header h1 { font-size: 2rem; font-weight: 700; line-height: 1.3; margin-bottom: 12px; }
.article-meta { display: flex; gap: 16px; font-size: 0.875rem; color: var(--color-text-muted); align-items: center; flex-wrap: wrap; }
.article-tags { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* Article Layout (TOC + Content) */
.article-layout { display: flex; align-items: flex-start; }
.article-layout .article-detail { flex: 1; min-width: 0; max-width: none; }

/* TOC - 负 margin 左移，不占正文空间 */
.article-toc {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-height, 60px) + 20px);
  max-height: calc(100vh - var(--header-height, 60px) - 40px);
  overflow-y: auto;
  margin-left: -228px;
  margin-right: 28px;
}
.toc-title { font-weight: 600; font-size: 0.9375rem; margin-bottom: 12px; color: var(--color-text); }
.toc-nav { display: flex; flex-direction: column; gap: 2px; }
.toc-link {
  display: block;
  padding: 5px 0 5px 12px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  border-left: 2px solid var(--color-border);
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc-link:hover { color: var(--color-primary); border-left-color: var(--color-primary); }
.toc-link.active { color: var(--color-primary); border-left-color: var(--color-primary); font-weight: 600; background: var(--color-primary-bg, transparent); }
.toc-level-1 { padding-left: 0; }
.toc-level-2 { padding-left: 12px; }
.toc-level-3 { padding-left: 24px; }
.toc-level-4 { padding-left: 36px; }
.toc-level-5 { padding-left: 48px; }
.toc-level-6 { padding-left: 60px; }

/* Markdown Content */
.markdown-body { font-size: 1rem; line-height: 1.8; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin-top: 1.5em; margin-bottom: 0.5em; font-weight: 600; }
.markdown-body h2 { font-size: 1.5rem; padding-bottom: 8px; border-bottom: 1px solid var(--color-border); }
.markdown-body h3 { font-size: 1.25rem; }
.markdown-body p { margin-bottom: 1em; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5em; margin-bottom: 1em; }
.markdown-body ul { list-style: disc; }
.markdown-body ol { list-style: decimal; }
.markdown-body li { margin-bottom: 0.25em; }
.markdown-body code { background: var(--color-bg-secondary); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
/* 行内代码多样式 */
.markdown-body code.code-style-plain { background: #f1f3f5; color: #d6336c; }
.markdown-body code.code-style-red { background: #fff5f5; color: #e03131; border: 1px solid #ffc9c9; }
.markdown-body code.code-style-green { background: #ebfbee; color: #2f9e44; border: 1px solid #b2f2bb; }
.markdown-body code.code-style-blue { background: #e7f5ff; color: #1c7ed6; border: 1px solid #a5d8ff; }
.markdown-body code.code-style-yellow { background: #fff9db; color: #e67700; border: 1px solid #ffec99; }
.markdown-body pre { background: #282c34; color: #abb2bf; padding: 20px; border-radius: var(--radius); overflow-x: auto; margin-bottom: 1em; position: relative; }
.markdown-body pre code { background: none; padding: 0; color: inherit; }

/* 代码块复制按钮 */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #a0aec0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
  z-index: 1;
}
.markdown-body pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.code-copy-btn.copied { background: rgba(76, 175, 80, 0.3); color: #81c784; border-color: rgba(76, 175, 80, 0.5); }

/* 手机端复制按钮常驻显示 */
@media (max-width: 768px) {
  .code-copy-btn { opacity: 1; }
}
.markdown-body blockquote { border-left: 4px solid var(--color-primary); padding: 12px 20px; background: var(--color-primary-bg); border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 1em; }
.markdown-body img { border-radius: var(--radius); margin: 1em 0; }
.markdown-body a { color: var(--color-primary); text-decoration: underline; }
.markdown-body table { width: 100%; border-collapse: collapse; margin-bottom: 1em; }
.markdown-body th, .markdown-body td { border: 1px solid var(--color-border); padding: 10px 14px; text-align: left; }
.markdown-body th { background: var(--color-bg-secondary); font-weight: 600; }

/* === 文件附件 === */
.markdown-body .article-attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  margin: 4px 0;
  background: var(--color-bg-secondary, #f8f9fa);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 6px;
  color: var(--color-text, #1f2937);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.2s;
}
.markdown-body .article-attachment:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.markdown-body .article-attachment .att-icon { font-size: 1rem; }
.markdown-body .article-attachment .att-name { font-weight: 500; }
.markdown-body .article-attachment .att-size {
  font-size: 0.75rem;
  color: var(--color-text-muted, #9ca3af);
  padding-left: 8px;
  border-left: 1px solid var(--color-border, #e5e7eb);
}

/* === B站视频（响应式 16:9） === */
.markdown-body .bili-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 1em 0;
  border-radius: var(--radius, 8px);
  overflow: hidden;
  background: #000;
}
.markdown-body .bili-video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* === 文章内嵌目录 === */
.markdown-body .article-toc-inline {
  margin: 1.5em 0;
  padding: 16px 20px;
  background: var(--color-bg-secondary, #f8f9fa);
  border: 1px solid var(--color-border, #e5e7eb);
  border-left: 4px solid var(--color-primary);
  border-radius: 0 var(--radius, 8px) var(--radius, 8px) 0;
}
.markdown-body .article-toc-inline .toc-inline-title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 10px;
  color: var(--color-text, #1f2937);
}
.markdown-body .article-toc-inline ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.markdown-body .article-toc-inline .toc-inline-item a {
  display: block;
  padding: 4px 8px;
  font-size: 0.875rem;
  color: var(--color-text-secondary, #6b7280);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.markdown-body .article-toc-inline .toc-inline-item a:hover {
  color: var(--color-primary);
  border-left-color: var(--color-primary);
}

/* === 提示框 alert（4色） === */
.markdown-body .alert {
  margin: 1em 0;
  padding: 12px 16px;
  border-radius: var(--radius, 8px);
  border-left: 4px solid;
  font-size: 0.9375rem;
  line-height: 1.6;
}
.markdown-body .alert p:first-child { margin-top: 0; }
.markdown-body .alert p:last-child { margin-bottom: 0; }
.markdown-body .alert-info {
  background: #e7f5ff;
  border-left-color: #1c7ed6;
  color: #0b4a8a;
}
.markdown-body .alert-warning {
  background: #fff9db;
  border-left-color: #f08c00;
  color: #7c4800;
}
.markdown-body .alert-danger {
  background: #fff5f5;
  border-left-color: #e03131;
  color: #a02020;
}
.markdown-body .alert-success {
  background: #ebfbee;
  border-left-color: #2f9e44;
  color: #1a6b2c;
}

/* === 可折叠区块 details === */
.markdown-body details {
  margin: 1em 0;
  padding: 0;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius, 8px);
  overflow: hidden;
}
.markdown-body details summary {
  padding: 10px 16px;
  background: var(--color-bg-secondary, #f8f9fa);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.markdown-body details summary::-webkit-details-marker { display: none; }
.markdown-body details summary::before {
  content: '▸';
  display: inline-block;
  transition: transform 0.2s;
  color: var(--color-text-muted, #9ca3af);
}
.markdown-body details[open] summary::before { transform: rotate(90deg); }
.markdown-body details summary:hover { background: var(--color-bg-hover, #f1f3f5); }
.markdown-body details > *:not(summary) { padding: 0 16px; }
.markdown-body details > *:last-child { padding-bottom: 14px; }

/* Related */
.related-articles { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--color-border); }
.related-articles h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 16px; }
.related-articles .card { padding: 14px 16px; }
.related-articles .card-title { font-size: 1rem; margin-bottom: 4px; line-height: 1.4; }
.related-articles .card-title a { display: block; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.related-articles .card p { font-size: 0.75rem !important; margin-top: 2px !important; }

@media (max-width: 768px) {
  .related-articles { margin-top: 32px; padding-top: 20px; }
  .related-articles h2 { font-size: 1rem; margin-bottom: 12px; }
  .related-articles .grid-2 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .related-articles .card { padding: 10px 12px; }
  .related-articles .card-title { font-size: 0.875rem; }
  .related-articles .card p { font-size: 0.6875rem !important; }
}
@media (max-width: 380px) {
  .related-articles .card { padding: 8px 10px; }
  .related-articles .card-title { font-size: 0.8125rem; }
}

@media (max-width: 1400px) {
  .article-toc { display: none; }
  .article-layout .article-detail { max-width: 800px; margin: 0 auto; }
}

/* 手机端 TOC 按钮（< 1400px 显示） - fixed 浮动在右下角 */
.toc-mobile-btn {
  display: none;
  position: fixed;
  bottom: 88px;
  right: 32px;
  padding: 8px 14px;
  border-radius: 18px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1.1;
  font-size: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 999;
  transition: all 0.3s;
}
.toc-mobile-btn span {
  font-size: 0.75rem;
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 1px;
  line-height: 1;
}
.toc-mobile-btn:hover { background: var(--color-primary-dark); transform: translateY(-2px); }
@media (max-width: 1399px) {
  .toc-mobile-btn { display: flex; }
}
@media (max-width: 768px) {
  .toc-mobile-btn { bottom: 76px; right: 20px; padding: 6px 12px; font-size: 0.6875rem; }
  .toc-mobile-btn span { font-size: 0.6875rem; }
}

/* 手机端 TOC 抽屉 */
.toc-mobile-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 3000;
}
.toc-mobile-overlay.open { display: block; }
.toc-mobile-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: #fff;
  z-index: 3001;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
}
.toc-mobile-drawer.open { transform: translateX(0); }
.toc-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.toc-mobile-title { font-weight: 600; font-size: 1rem; }
.toc-mobile-close {
  font-size: 24px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 0;
}
.toc-mobile-close:hover { color: var(--color-text); }
.toc-mobile-drawer .toc-nav {
  padding: 12px 20px;
  overflow-y: auto;
  flex: 1;
}
.toc-mobile-drawer .toc-link {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  padding: 8px 0 8px 12px;
}
@media (max-width: 768px) {
  .article-header h1 { font-size: 1.5rem; }
  .article-detail { max-width: 100%; }
}
