/* doc.css — 项目文档页通用样式（文档列表 + 查看器 + 渲染后的 Markdown 排版） */
:root {
  --ink: #0f172a; --muted: #64748b; --rule: rgba(15,23,42,0.09);
  --glass: rgba(255,255,255,0.78);
  --glass-border: rgba(255,255,255,0.65);
  --accent: #4f46e5;
  --shadow: 0 1px 3px rgba(2,6,23,0.06), 0 1px 2px rgba(2,6,23,0.04);
  --shadow-lg: 0 16px 40px -16px rgba(2,6,23,0.18);
  --radius: 18px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', -apple-system, sans-serif;
  color: var(--ink); font-size: 15px; line-height: 1.75;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
  background:
    radial-gradient(ellipse 55% 42% at 12% -5%, rgba(124,58,237,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 88% 8%, rgba(6,182,212,0.12) 0%, transparent 60%),
    linear-gradient(160deg, #f6f7ff 0%, #f0f9ff 50%, #fff7f2 100%);
  background-attachment: fixed;
}
.nav { position: sticky; top: 0; z-index: 100; background: rgba(255,255,255,0.78); backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%); border-bottom: 1px solid var(--rule); }
.nav-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; justify-content: space-between; }
.nav-logo { font-size: 15px; font-weight: 800; text-decoration: none; color: var(--ink); background: linear-gradient(120deg,#4f46e5,#06b6d4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.nav-links { display: flex; gap: 6px; }
.nav-links a { font-size: 14px; color: var(--muted); text-decoration: none; padding: 7px 14px; border-radius: 10px; transition: all 0.2s; font-weight: 500; }
.nav-links a:hover { color: var(--accent); background: rgba(79,70,229,0.08); }
.nav-links a.active { color: var(--accent); background: rgba(79,70,229,0.1); font-weight: 700; }
.nav-ham { display: none; background: none; border: none; font-size: 22px; color: var(--ink); cursor: pointer; }
@media (max-width: 720px) {
  .nav-links { display: none; position: absolute; top: 60px; left: 0; right: 0; background: rgba(255,255,255,0.96); border-bottom: 1px solid var(--rule); padding: 12px; flex-direction: column; }
  .nav-links.open { display: flex; }
  .nav-ham { display: block; }
}
.container { max-width: 1200px; margin: 0 auto; padding: 30px 24px 24px; }
.doc-head { margin-bottom: 22px; }
.doc-head h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.doc-head .sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.doc-back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--accent); text-decoration: none; font-weight: 600; margin-bottom: 12px; }
.doc-back:hover { text-decoration: underline; }

/* ===== 布局：左侧文档列表 + 右侧查看器 ===== */
.doc-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: start; }
.doc-side { position: sticky; top: 84px; display: flex; flex-direction: column; min-width: 0; }
.doc-nav { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.doc-nav-item {
  text-align: left; cursor: pointer; font-family: inherit;
  background: var(--glass); backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow); transition: all 0.2s;
}
.doc-nav-item:hover { border-color: var(--accent); transform: translateX(2px); }
.doc-nav-item.active { border-color: transparent; background: linear-gradient(120deg,#4f46e5,#06b6d4); color: #fff; }
.doc-nav-item .dni-title { display: block; font-size: 13.5px; font-weight: 700; line-height: 1.4; }
.doc-nav-item .dni-meta { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.doc-nav-item.active .dni-meta { color: rgba(255,255,255,0.82); }
.doc-more-title { font-size: 12px; font-weight: 700; color: var(--muted); margin: 20px 0 8px; letter-spacing: 0.06em; }
.doc-more { display: flex; flex-direction: column; gap: 8px; }
.more-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--glass-border);
  border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); text-decoration: none; color: inherit; transition: all 0.2s;
}
.more-row:hover { border-color: var(--accent); transform: translateX(2px); }
.more-row .mr-title { font-size: 13px; font-weight: 700; line-height: 1.4; }
.more-row .mr-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.more-row .mr-btn { font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap; flex-shrink: 0; }

/* ===== 查看器 ===== */
.doc-viewer {
  background: var(--glass); backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 26px 30px; min-height: 60vh;
  min-width: 0; max-width: 100%;
}
.doc-view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid var(--rule); }
.doc-view-head h2 { font-size: 1.2rem; font-weight: 800; line-height: 1.4; padding-left: 12px; border-left: 4px solid var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 700; text-decoration: none; transition: all 0.2s; white-space: nowrap; }
.btn-primary { color: #fff; background: linear-gradient(120deg,#4f46e5,#06b6d4); box-shadow: 0 6px 16px -6px rgba(79,70,229,0.55); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-outline { color: var(--ink); background: rgba(255,255,255,0.7); border: 1.5px solid rgba(15,23,42,0.12); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ===== 渲染后的 Markdown 排版 ===== */
.md-body { font-size: 14.5px; color: #334155; }
.md-body > *:first-child { margin-top: 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { color: var(--ink); font-weight: 800; letter-spacing: -0.01em; margin: 22px 0 10px; line-height: 1.4; }
.md-body h1 { font-size: 1.45rem; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.md-body h2 { font-size: 1.22rem; }
.md-body h3 { font-size: 1.05rem; }
.md-body h4 { font-size: 0.98rem; }
.md-body p { margin: 8px 0; }
.md-body ul, .md-body ol { margin: 8px 0 8px 22px; }
.md-body li { margin: 3px 0; }
.md-body li > ul, .md-body li > ol { margin: 2px 0 2px 18px; }
.md-body strong { color: var(--ink); }
.md-body a { color: var(--accent); text-decoration: none; border-bottom: 1px dashed rgba(79,70,229,0.4); }
.md-body a:hover { border-bottom-style: solid; }
.md-body code {
  font-family: 'Consolas', 'SFMono-Regular', Menlo, monospace;
  background: rgba(79,70,229,0.08); color: #4338ca;
  padding: 1px 6px; border-radius: 5px; font-size: 13px;
}
.md-body pre {
  background: #0f172a; color: #e2e8f0; border-radius: 12px;
  padding: 16px 18px; overflow-x: auto; margin: 12px 0;
}
.md-body pre code { background: none; color: inherit; padding: 0; font-size: 13px; line-height: 1.6; }
.md-body blockquote {
  border-left: 3px solid var(--accent);
  background: rgba(79,70,229,0.05);
  padding: 10px 16px; margin: 12px 0; border-radius: 0 10px 10px 0; color: #475569;
}
.md-body table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13.5px; display: block; overflow-x: auto; }
.md-body th, .md-body td { border: 1px solid rgba(15,23,42,0.1); padding: 8px 12px; text-align: left; vertical-align: top; }
.md-body th { background: rgba(79,70,229,0.07); color: var(--ink); font-weight: 700; }
.md-body tr:nth-child(even) td { background: rgba(15,23,42,0.02); }
.md-body hr { border: none; border-top: 1px solid var(--rule); margin: 20px 0; }
.md-body img { max-width: 100%; border-radius: 10px; border: 1px solid var(--rule); }
.md-body .md-mermaid { text-align: center; margin: 14px 0; overflow-x: auto; }
.md-body .md-mermaid svg { max-width: 100%; height: auto; }
.md-body .md-mermaid-fallback { text-align: left; }
.md-body .md-mermaid-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

footer { text-align: center; padding: 40px 0; color: var(--muted); font-size: 13px; }
footer a { color: var(--accent); text-decoration: none; }

@media (max-width: 900px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .doc-side { position: static; }
  .doc-nav {
    flex-direction: row; overflow-x: auto; padding-bottom: 10px;
    -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }
  .doc-nav::after {
    content: '← 左右滑动切换文档 →';
    display: block; position: absolute; right: 0; top: 100%;
    font-size: 11px; color: var(--muted); opacity: 0.75;
    padding-top: 4px; pointer-events: none;
  }
  .doc-nav { position: relative; }
  .doc-nav-item {
    min-width: 210px; flex-shrink: 0; scroll-snap-align: start;
  }
  .doc-nav-item:hover, .doc-nav-item.active { transform: none; }
  .doc-more { flex-direction: row; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
  .more-row { min-width: 230px; flex-shrink: 0; }
}
@media (max-width: 560px) {
  .container { padding: 20px 14px 20px; }
  .doc-viewer { padding: 18px 16px; }
  .doc-head h1 { font-size: 1.35rem; }
  .md-body { font-size: 14px; }
  .md-body pre { padding: 12px 12px; font-size: 12px; }
  .md-body table { font-size: 12.5px; }
}
@media print { .nav, footer, .doc-side { display: none; } .doc-layout { display: block; } body { background: #fff; } }
