/* ============================================================
   doc.css — 文档页样式：.md-body、error
   ============================================================ */

.container {
  max-width: 1180px;
}

.doc-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 0 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.doc-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 20px;
  align-items: start;
}

.md-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  margin-top: 24px;
  transition: all .3s;
  min-width: 0;
  overflow: hidden;
}

.doc-outline {
  position: sticky;
  top: 72px;
  margin-top: 24px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 16px 0 16px 18px;
  border-left: 1px solid var(--border);
  transition: border-color .3s;
}

.doc-outline[hidden] {
  display: none;
}

.doc-outline-title {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.doc-outline ol {
  list-style: none;
}

.doc-outline li {
  margin-bottom: 2px;
}

.doc-outline a {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 5px 0;
  text-decoration: none;
  transition: color .2s;
}

.doc-outline a:hover,
.doc-outline a:focus-visible {
  color: var(--accent);
}

.doc-outline a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.doc-outline .outline-level-h3 {
  padding-left: 12px;
}

.md-body h2,
.md-body h3 {
  scroll-margin-top: 84px;
}

.md-body h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--header-gradient-1) 30%, var(--header-gradient-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-wrap: anywhere;
}

.md-body h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  overflow-wrap: anywhere;
}

.md-body h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 12px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.md-body p {
  margin-bottom: 14px;
  color: var(--text);
}

.md-body a {
  color: var(--accent);
  text-decoration: none;
}
.md-body a:hover { text-decoration: underline; }

.md-body strong { color: var(--text); font-weight: 600; }

.md-body ul, .md-body ol {
  margin: 12px 0 16px 24px;
}

.md-body li {
  margin-bottom: 6px;
  color: var(--text);
}

.md-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.md-body blockquote {
  border-left: 4px solid var(--accent);
  margin: 16px 0;
  padding: 10px 20px;
  background: rgba(108, 99, 255, .06);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
}
.md-body blockquote p { margin-bottom: 0; }

.md-body code {
  background: rgba(108, 99, 255, .1);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--cyan);
}

.md-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  max-width: 100%;
  margin: 16px 0;
}

.md-body pre code {
  background: none;
  display: block;
  min-width: max-content;
  padding: 0;
  color: var(--text);
  font-size: 0.85em;
  line-height: 1.6;
}

.md-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
}

.md-body th, .md-body td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}

.md-body th {
  background: var(--bg);
  font-weight: 600;
}

/* ---- Error ---- */
.md-body .error {
  text-align: center;
  padding: 60px 0;
  color: #ef4444;
}

/* ---- Images ---- */
.md-body img {
  max-width: 600px;
  max-height: 400px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 16px 0;
  display: block;
  cursor: zoom-in;
  transition: transform .2s;
}
.md-body img:hover {
  transform: scale(1.02);
}

/* ---- Lightbox ---- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 999;
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 0 40px rgba(0,0,0,.5);
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .doc-shell { gap: 14px; }
  .md-body { padding: 24px 18px; }
  .md-body h1 { font-size: 1.5rem; }
  .md-body img { max-width: 100%; max-height: 300px; }
}

@media (max-width: 980px) {
  .container { max-width: 780px; }
  .doc-shell { grid-template-columns: 1fr; }
  .doc-outline {
    position: static;
    order: -1;
    max-height: none;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }
  .doc-outline ol {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 12px;
  }
  .doc-outline .outline-level-h3 {
    padding-left: 0;
  }
}

@media (max-width: 520px) {
  .doc-outline ol { grid-template-columns: 1fr; }
}
