html {
  font-size: 14px;
  height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 14px;
  }
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow:
    0 0 0 0.1rem white,
    0 0 0 0.25rem #258cfb;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  margin: 0;
}

/* 顶栏搜索：单行高度，按钮文字横向不换行 */
.site-header-search {
  flex-wrap: nowrap;
}

.site-header-search .form-control {
  line-height: 1.25;
}

.site-header-search .btn {
  writing-mode: horizontal-tb;
}

.admin-article-table .admin-article-summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ------------------------------------------------------------------ */
/* 文章正文：简洁文档风（居中、留白、中英混排无衬线）                  */
/* ------------------------------------------------------------------ */

.article-shell {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}

/* 正文 + 右侧问答导航 */
.article-layout {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 0.65rem;
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}

.article-layout__main {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 860px;
}

/* 右侧轨道：大屏随文 sticky；小屏贴右缘固定，避免挡正文 */
.qa-nav-rail {
  flex: 0 0 40px;
  width: 40px;
  position: sticky;
  top: 5rem;
  align-self: flex-start;
  max-height: calc(100vh - 6rem);
  z-index: 20;
}

.qa-nav-rail__scroller {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: inherit;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.35rem 0;
  scrollbar-width: thin;
}

.qa-nav-rail__line {
  position: absolute;
  left: 50%;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  margin-left: -1px;
  background: #d0d7de;
  border-radius: 1px;
  pointer-events: none;
}

.qa-nav-rail__markers {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: 0.35rem 0;
}

.qa-nav-rail__marker {
  flex-shrink: 0;
  width: 11px;
  min-height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  /* 未定位到该问：灰色、缩小 */
  background: #aeb8c2;
  cursor: pointer;
  transform: scale(0.68);
  transform-origin: center center;
  opacity: 0.92;
  transition:
    background-color 0.22s ease,
    transform 0.22s ease,
    opacity 0.22s ease;
}

.qa-nav-rail__marker:not(.qa-nav-rail__marker--active):hover,
.qa-nav-rail__marker:not(.qa-nav-rail__marker--active):focus-visible {
  background: #949da8;
  transform: scale(0.78);
  opacity: 1;
  outline: none;
}

/* 当前滚动到的问答：黑色、正常尺寸 */
.qa-nav-rail__marker--active {
  background: #1f2328;
  transform: scale(1);
  opacity: 1;
}

.qa-nav-rail__marker--active:hover,
.qa-nav-rail__marker--active:focus-visible {
  background: #24292f;
  transform: scale(1);
  opacity: 1;
}

.qa-nav-rail__tooltip {
  position: fixed;
  z-index: 1095;
  max-width: min(320px, calc(100vw - 48px));
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: #24292f;
  background: #fff;
  border-radius: 12px;
  box-shadow:
    0 4px 24px rgba(31, 35, 40, 0.18),
    0 0 0 1px rgba(208, 215, 222, 0.6);
  pointer-events: none;
}

.qa-nav-rail__tooltip--visible {
  animation: qa-nav-tooltip-in 0.12s ease-out;
}

@keyframes qa-nav-tooltip-in {
  from {
    opacity: 0;
    transform: translateX(6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 小屏：轨道贴右，正文留空 */
@media (max-width: 767.98px) {
  .article-layout {
    padding-right: 36px;
  }

  .qa-nav-rail {
    position: fixed;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    flex: none;
    width: 32px;
    max-height: min(72vh, 560px);
  }

  .qa-nav-rail__markers {
    gap: 1rem;
  }

  .qa-nav-rail__marker {
    width: 10px;
    min-height: 20px;
  }
}

/* 全屏问答预览（小屏：竖向列表 + 上下滚动） */
.qa-nav-mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
}

.qa-nav-mobile-overlay[hidden] {
  display: none !important;
}

.qa-nav-mobile-overlay__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(15, 23, 42, 0.4);
}

.qa-nav-mobile-overlay__sheet {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  background: #fff;
  overflow: hidden;
  box-sizing: border-box;
}

.qa-nav-mobile-overlay__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: calc(0.65rem + env(safe-area-inset-top, 0px)) 1rem 0.65rem;
  background: #fff;
  border-bottom: 1px solid #d0d7de;
}

.qa-nav-mobile-overlay__title {
  font-size: 1rem;
  font-weight: 600;
  color: #24292f;
}

.qa-nav-mobile-overlay__close {
  border: 0;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  color: #57606a;
  cursor: pointer;
  border-radius: 6px;
}

.qa-nav-mobile-overlay__close:focus-visible {
  outline: 2px solid #0969da;
}

.qa-nav-mobile-overlay__list-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.qa-nav-mobile-overlay__list {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.qa-nav-mobile-overlay__item {
  width: 100%;
  display: block;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #d0d7de;
  background: #fff;
  padding: 1rem 1.15rem;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.12s ease;
}

.qa-nav-mobile-overlay__item:active {
  background: #f6f8fa;
}

.qa-nav-mobile-overlay__item:focus-visible {
  outline: 2px solid #0969da;
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}

.qa-nav-mobile-overlay__item:last-child {
  border-bottom: 0;
}

.qa-nav-mobile-overlay__preview {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: #24292f;
}

body.qa-nav-mobile-overlay-open {
  overflow: hidden;
}

.article-title-display {
  font-size: clamp(1.35rem, 2.5vw, 1.65rem);
  font-weight: 600;
  line-height: 1.35;
  color: #24292f;
  letter-spacing: -0.02em;
}

.markdown-doc-surface {
  --md-text: #24292f;
  --md-muted: #57606a;
  --md-border: #d0d7de;
  --md-link: #0969da;

  background: #ffffff;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  border-radius: 8px;
}

.markdown-doc-surface.markdown-doc-surface--ready {
  min-height: 0;
}

/* Grok 问答导出：问/答分段、轮次间距、问后分割线 */
.markdown-doc-surface .markdown-body.markdown-qa {
  display: block;
}

.markdown-doc-surface .markdown-qa__preamble {
  margin-bottom: 1.35rem;
}

.markdown-doc-surface .markdown-qa__round + .markdown-qa__round {
  margin-top: 2.35rem;
}

.markdown-doc-surface .markdown-qa__round {
  scroll-margin-top: 5rem;
}

/* 问题区：淡边框 + 左上「提问」角标，便于快速扫视定位 */
.markdown-doc-surface .markdown-qa__question {
  position: relative;
  margin-top: 0.35rem;
  margin-bottom: 0;
  padding: 1.25rem 0.9rem 0.85rem;
  border: 1px solid rgba(208, 215, 222, 0.5);
  border-radius: 6px;
  background: rgba(246, 248, 250, 0.4);
}

.markdown-doc-surface .markdown-qa__question::before {
  content: "提问";
  position: absolute;
  top: -0.5rem;
  left: 0.65rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.2;
  color: white;
  background: royalblue;
  border: 1px solid rgba(208, 215, 222, 0.45);
  border-radius: 3px;
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
}

.markdown-doc-surface .markdown-qa__round > hr.markdown-qa__hr {
  margin: 1.35rem 0 0.5rem;
  border: 0;
  border-top: 1px solid var(--md-border);
}

.markdown-doc-surface .markdown-qa__answer {
  margin-top: 0;
}

.markdown-doc-surface .markdown-body {
  font-family:
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    "Helvetica Neue", Helvetica, Arial, ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--md-text);
  -webkit-font-smoothing: antialiased;
}

.markdown-doc-surface .markdown-body > :first-child {
  margin-top: 0;
}

.markdown-doc-surface .markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-doc-surface .markdown-body p {
  margin-bottom: 1rem;
}

.markdown-doc-surface .markdown-body h1,
.markdown-doc-surface .markdown-body h2,
.markdown-doc-surface .markdown-body h3,
.markdown-doc-surface .markdown-body h4,
.markdown-doc-surface .markdown-body h5,
.markdown-doc-surface .markdown-body h6 {
  font-weight: 600;
  line-height: 1.35;
  color: var(--md-text);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.markdown-doc-surface .markdown-body h1 {
  font-size: 1.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--md-border);
}

.markdown-doc-surface .markdown-body h2 {
  font-size: 1.3rem;
}

.markdown-doc-surface .markdown-body h3 {
  font-size: 1.15rem;
}

.markdown-doc-surface .markdown-body ul,
.markdown-doc-surface .markdown-body ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.markdown-doc-surface .markdown-body ul {
  list-style-type: disc;
}

.markdown-doc-surface .markdown-body ol {
  list-style-type: decimal;
}

.markdown-doc-surface .markdown-body li {
  margin-bottom: 0.35rem;
}

.markdown-doc-surface .markdown-body li > p {
  margin-bottom: 0.5rem;
}

.markdown-doc-surface .markdown-body ul ul,
.markdown-doc-surface .markdown-body ol ul {
  list-style-type: circle;
  margin-top: 0.35rem;
  margin-bottom: 0.35rem;
}

.markdown-doc-surface .markdown-body ul ul ul,
.markdown-doc-surface .markdown-body ol ol ul,
.markdown-doc-surface .markdown-body ul ol ul {
  list-style-type: square;
}

.markdown-doc-surface .markdown-body blockquote {
  margin: 1rem 0;
  padding: 0 0 0 1rem;
  border-left: 4px solid var(--md-border);
  color: var(--md-muted);
}

.markdown-doc-surface .markdown-body blockquote > :last-child {
  margin-bottom: 0;
}

.markdown-doc-surface .markdown-body hr {
  margin: 1.75rem 0;
  border: 0;
  border-top: 1px solid var(--md-border);
}

.markdown-doc-surface .markdown-body a {
  color: var(--md-link);
  text-decoration: none;
}

.markdown-doc-surface .markdown-body a:hover {
  text-decoration: underline;
}

.markdown-doc-surface .markdown-body strong {
  font-weight: 600;
  color: var(--md-text);
}

/* 行内 code（排除代码块内的 code，避免与 highlight.js 冲突） */
.markdown-doc-surface .markdown-body :not(pre) > code {
  font-family:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  padding: 0;
  background: transparent;
  border-radius: 0;
  border: 0;
}

.markdown-doc-surface .markdown-body pre {
  overflow: visible;
  max-width: 100%;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.markdown-doc-surface .markdown-body pre code {
  padding: 0;
  border: 0;
  font-size: inherit;
  background: transparent !important;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* highlight.js 着色后的代码块（@section Head 中主题晚于 site.css，需覆盖背景/滚动/内边距） */
.markdown-doc-surface .markdown-body pre code.hljs {
  display: block;
  overflow: visible !important;
  padding: 0 !important;
  background: transparent !important;
  white-space: pre-wrap !important;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* 代码块工具栏（Article 正文由 article-code-blocks.js 包装） */
.markdown-doc-surface .markdown-body .code-block-shell {
  margin-bottom: 1rem;
  border: 1px solid var(--md-border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.markdown-doc-surface .markdown-body .code-block-shell__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.55rem 0.4rem 0.65rem;
  background: #f8f9fa;
  user-select: none;
}

.markdown-doc-surface
  .markdown-body
  .code-block-shell:not(.code-block-shell--collapsed)
  .code-block-shell__header {
  border-bottom: 1px solid var(--md-border);
}

.markdown-doc-surface .markdown-body .code-block-shell__label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--md-muted);
}

.markdown-doc-surface .markdown-body .code-block-shell__code-icon {
  display: inline-flex;
  color: #6e7781;
  flex-shrink: 0;
}

.markdown-doc-surface .markdown-body .code-block-shell__lang {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.markdown-doc-surface .markdown-body .code-block-shell__actions {
  display: flex;
  align-items: center;
  gap: 0.05rem;
  flex-shrink: 0;
}

.markdown-doc-surface .markdown-body .code-block-shell__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #57606a;
  cursor: pointer;
  transition:
    background-color 0.12s ease,
    color 0.12s ease;
}

.markdown-doc-surface .markdown-body .code-block-shell__btn:hover {
  background: rgba(31, 35, 40, 0.08);
  color: var(--md-text);
}

.markdown-doc-surface .markdown-body .code-block-shell__btn:focus-visible {
  outline: 2px solid var(--md-link);
  outline-offset: 1px;
}

.markdown-doc-surface
  .markdown-body
  .code-block-shell__btn
  .code-block-shell__svg {
  display: block;
}

.markdown-doc-surface .markdown-body .code-block-shell__body {
  background: #fff;
}

.markdown-doc-surface .markdown-body .code-block-shell__body pre {
  margin: 0;
  padding: 0.65rem 0.85rem 0.85rem;
}

.markdown-doc-surface
  .markdown-body
  .code-block-shell--collapsed
  .code-block-shell__body {
  display: none;
}

.markdown-doc-surface
  .markdown-body
  .code-block-shell__btn--toggle
  .code-block-shell__chevron {
  transition: transform 0.18s ease;
  display: block;
}

.markdown-doc-surface
  .markdown-body
  .code-block-shell__btn--toggle.is-collapsed
  .code-block-shell__chevron {
  transform: rotate(180deg);
}

.markdown-doc-surface .markdown-body table {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: collapse;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
}

.markdown-doc-surface .markdown-body table th,
.markdown-doc-surface .markdown-body table td {
  border: 1px solid var(--md-border);
  padding: 0.5rem 0.75rem;
}

.markdown-doc-surface .markdown-body table th {
  font-weight: 600;
  background: #f6f8fa;
}

.markdown-doc-surface .markdown-body table tr:nth-child(even) {
  background: #fafbfc;
}

.markdown-doc-surface .markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* 兼容：未包在 .markdown-doc-surface 内的片段（如其它页） */
.markdown-body pre {
  overflow: visible;
  max-width: 100%;
  padding: 0.75rem 0;
  background: transparent;
  border-radius: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.markdown-body pre code {
  background: transparent !important;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.markdown-body table {
  width: 100%;
  margin-bottom: 1rem;
}

.markdown-body img {
  max-width: 100%;
  height: auto;
}
