/* /doc 文档页面样式。
 *
 * 自写而非复用前端构建产物：这三个页面要能脱离 SPA 独立渲染，
 * 且响应式断点由这里统一掌控（需求 13：PC 与移动端自适应）。
 * 只依赖系统字体，不引入外部字体资源，避免首屏阻塞与额外请求。
 */

:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #e5e7eb;
  /* 品牌色必须与前端 tailwind 的 primary 一致（primary-600 / primary-50）。
     此前这里是蓝色 #2563eb，而 SPA 端导航高亮用的是 primary-600 青色，
     导致「文章/tag 页高亮是蓝的、首页和模型广场是青的」——同站两套品牌色。 */
  --brand: #0d9488;
  --brand-soft: #f0fdfa;
  --brand-hover: #0f766e;   /* primary-700 */
  --radius: 10px;
  --wrap: 1200px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------------------------------------------------------------- 顶部导航 */
.doc-nav {
  /* 与 SPA 顶栏 AppHeader/PlazaNavBar 的 glass 样式对齐：
     半透明白 + 背景模糊。此前是纯白实心，和首页顶栏观感不同。 */
  background: rgba(255, 255, 255, 0.8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.5);
  position: sticky;
  top: 0;
  z-index: 20;
}
.doc-nav-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 16px;
  /* 64px + 1px 下边框 = 65px，与 SPA 端顶栏（SiteNav / PlazaNavBar）等高。
     之前是 56px，切换页面时导航栏会跳一下高低。 */
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
}
/* 品牌区：图标 + 站名，与 SPA 顶栏一致（首页/模型广场都是「图标在左、站名在右」）。
   此前只有一行文字，没有图标。 */
.doc-brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
}
.doc-brand-logo {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 10px;
  object-fit: contain;
}
.doc-brand-name { white-space: nowrap; }

/* 折叠容器：宽屏下 display:contents —— 元素本身不产生盒子，
   .doc-links 就像直接挂在 .doc-nav-inner 下一样参与横向布局。
   这样桌面端与改造前的渲染结果完全一致，只有窄屏才变成下拉面板。 */
.doc-nav-collapse { display: contents; }

/* 折叠开关与遮罩：默认（宽屏）隐藏 */
.doc-nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.doc-nav-btn { display: none; }
.doc-nav-backdrop { display: none; }

/* 导航项：横向排列，窄屏折叠为下拉面板。
   当前项带背景高亮 + 加粗，一眼可辨所在栏目。 */
.doc-links {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  min-width: 0;
  scrollbar-width: none;   /* Firefox */
  -ms-overflow-style: none; /* 旧 Edge/IE */
}
.doc-links::-webkit-scrollbar { display: none; }

.doc-link {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  /* 500 对应 SPA 端 SiteNav 的 font-medium；此前是默认 400，
     导航文字在文档页明显比首页细。 */
  font-weight: 500;
  /* gray-600，与 SPA 端 SiteNav 的 text-gray-600 一致；
     之前用的 --muted(#6b7280) 比首页导航浅一档。 */
  color: #4b5563;
  transition: background 0.15s, color 0.15s;
}
.doc-link:hover { color: var(--brand); background: var(--brand-soft); }
.doc-link.active {
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 600;
}

/* ------------------------------------------------------------ 主体两栏布局 */
.doc-wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.doc-main { min-width: 0; }
.doc-side { position: sticky; top: 76px; }

/* ------------------------------------------------------------------ 通用块 */
.section-title,
.side-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
}
.side-card,
.list-head,
.post-list,
.article,
.related,
.gateway-box,
.agents,
.tag-posts {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.side-card { padding: 16px; }

/* 无封面时的首字母占位：比空白更易扫读，也不产生额外请求 */
.thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 18px;
}

/* -------------------------------------------------------------- 列表页 */
.list-head { padding: 18px 20px; margin-bottom: 16px; }
.list-head h1 { margin: 0; font-size: 22px; }
.list-sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.post-list { list-style: none; margin: 0; padding: 8px; }
.post-item + .post-item { border-top: 1px solid var(--line); }
.post-link { display: flex; gap: 14px; padding: 14px 12px; border-radius: 8px; }
.post-link:hover { background: #fafbfc; }
.post-thumb {
  flex: 0 0 150px;
  width: 150px;
  height: 100px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--brand-soft);
}
.post-thumb img { width: 100%; height: 100%; object-fit: cover; }
.post-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.post-title { font-size: 16px; font-weight: 600; line-height: 1.5; }
.post-link:hover .post-title { color: var(--brand); }
.pin {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border-radius: 4px;
  vertical-align: 1px;
}
.post-desc {
  color: var(--muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.dot { color: #cbd5e1; }

.list-empty, .side-empty { color: var(--muted); font-size: 13px; padding: 16px; margin: 0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.pager-btn {
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
}
.pager-btn:hover { border-color: var(--brand); color: var(--brand); }
.pager-btn.disabled { color: #cbd5e1; background: #f9fafb; }
.pager-info { font-size: 13px; color: var(--muted); }

/* -------------------------------------------------------------- 文章页 */
.article { padding: 24px 26px; }
.article-head { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 18px; }
/* 需求 11：标题层级与字号明确，正文行高放宽便于长文阅读 */
.article-title { margin: 0; font-size: 26px; line-height: 1.4; font-weight: 700; }
.article-meta { margin-top: 10px; color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; }
.article-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tag-chip {
  padding: 3px 10px;
  font-size: 12px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
}
.tag-chip:hover { background: #dbeafe; }

.article-body { font-size: 16px; line-height: 1.9; word-wrap: break-word; }
.article-body p { margin: 0 0 16px; }
.article-body h2 { font-size: 20px; margin: 28px 0 12px; padding-left: 10px; border-left: 4px solid var(--brand); }
.article-body h3 { font-size: 17px; margin: 22px 0 10px; }
.article-body img { border-radius: 8px; margin: 14px auto; }
.article-body a { color: var(--brand); text-decoration: underline; }
.article-body ul, .article-body ol { padding-left: 22px; margin: 0 0 16px; }
.article-body li { margin-bottom: 6px; }
.article-body blockquote {
  margin: 16px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--line);
  background: #fafbfc;
  color: var(--muted);
}
.article-body pre {
  margin: 16px 0;
  padding: 14px;
  background: #1f2328;
  color: #e5e7eb;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.article-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #f1f3f5;
  padding: 1px 5px;
  border-radius: 4px;
}
.article-body pre code { background: none; padding: 0; color: inherit; }
/* 正文里的表格在移动端容易溢出，包裹可横向滚动 */
.article-body table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.article-body th, .article-body td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }

.article-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.article-nav-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}
.article-nav-item:hover { border-color: var(--brand); }
.article-nav-item.next { text-align: right; }
.article-nav-item.disabled { color: #cbd5e1; background: #fafbfc; }
.article-nav-label { font-size: 12px; color: var(--muted); }
.article-nav-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------- 相关推荐 / tag 文章 */
.related, .tag-posts { margin-top: 16px; padding: 18px 20px; }
.related-title { font-size: 16px; margin: 0 0 14px; }
.related-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.related-item a { display: block; }
.related-thumb { display: block; height: 96px; border-radius: 8px; overflow: hidden; background: var(--brand-soft); }
.related-thumb img { width: 100%; height: 100%; object-fit: cover; }
.related-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.related-item a:hover .related-name { color: var(--brand); }

/* -------------------------------------------------------------- 右侧热门 */
.hot-list { list-style: none; margin: 0; padding: 0; }
.hot-item + .hot-item { border-top: 1px solid var(--line); }
.hot-link { display: flex; gap: 10px; padding: 10px 0; align-items: center; }
.hot-thumb { flex: 0 0 64px; width: 64px; height: 48px; border-radius: 6px; overflow: hidden; background: var(--brand-soft); }
.hot-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hot-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hot-name {
  font-size: 13px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hot-link:hover .hot-name { color: var(--brand); }
.hot-meta { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------ tag 页专有 */
.tag-head { padding: 4px 2px 14px; }
.tag-head .tag-name { margin: 0; font-size: 22px; }
.tag-sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.gateway-box { padding: 16px 20px; margin-bottom: 16px; }
.gateway-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.gateway-row { display: flex; gap: 10px; }
.gateway-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.gateway-copy {
  flex: 0 0 auto;
  padding: 10px 20px;
  font-size: 14px;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.gateway-copy:hover { background: var(--brand-hover); }
.gateway-copy.copied { background: #059669; }

.agents { padding: 18px 20px; margin-bottom: 16px; }
.agent-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.agent-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.agent-logo { width: 28px; height: 28px; object-fit: contain; }
.agent-badge {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
}
.agent-name { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.3; }

/* ---------------------------------------------------------------- 页脚 */
.doc-footer { border-top: 1px solid var(--line); background: var(--card); }
.doc-footer-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 18px 16px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.doc-footer-inner a:hover { color: var(--brand); }

/* ==========================================================================
   响应式（需求 13）
   三档：≥1024 两栏；768-1023 收窄右栏；<768 单栏，右栏移到正文之后。
   ========================================================================== */
@media (max-width: 1023px) {
  .doc-wrap { grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; }
  .related-list { grid-template-columns: repeat(2, 1fr); }
  .agent-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  body { font-size: 15px; }
  .doc-wrap { grid-template-columns: 1fr; padding: 12px 12px 32px; }
  /* 单栏时右侧热门排到正文之后，先看内容再看推荐 */
  .doc-side { position: static; order: 2; }
  .doc-main { order: 1; }

  /* 移动端：导航收成一个图标按钮，点击展开下拉面板。
     与 SPA 端 SiteNav 的交互一致（此前是横向滑动，用户很难发现）。 */
  .doc-nav { position: sticky; }
  .doc-nav-inner {
    /* 移动端同样 64px+1px，与 SPA 一致；此处曾从 56 改到 54，
       导致文档页比首页矮 10px。 */
    height: 64px;
    padding: 0 12px;
    gap: 8px;
  }
  .doc-brand { font-size: 15px; gap: 8px; }
  .doc-brand-logo { width: 32px; height: 32px; border-radius: 8px; }

  /* 开关放到品牌右侧 */
  .doc-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .doc-nav-btn:active { background: var(--brand-soft); }

  /* 窄屏下折叠容器变成要定位的下拉面板 */
  .doc-nav-collapse { display: block; position: relative; }

  .doc-links {
    display: none;
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    z-index: 30;
    min-width: 160px;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
    overflow: visible;
    white-space: normal;
  }
  .doc-link {
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 8px;
  }

  /* 展开状态：checkbox 用 :checked 驱动，纯 CSS、无需脚本 */
  .doc-nav-toggle:checked ~ .doc-nav-inner .doc-links { display: flex; }
  .doc-nav-toggle:checked ~ .doc-nav-inner .doc-nav-btn { background: var(--brand-soft); color: var(--brand); }

  /* 点击面板外任意处收起 */
  .doc-nav-toggle:checked ~ .doc-nav-backdrop {
    display: block;
    position: fixed;
    /* 顶部偏移必须等于导航栏实际高度（含 1px 下边框），否则遮罩会盖住
       导航项底部，导致展开面板后点不到菜单。 */
    inset: 65px 0 0 0;
    z-index: 25;
    background: transparent;
  }
  .doc-nav-backdrop { cursor: default; }

  .article { padding: 16px 14px; }
  .article-title { font-size: 21px; }
  .article-body { font-size: 16px; line-height: 1.85; }
  .article-body h2 { font-size: 18px; }
  .article-body pre { font-size: 12px; padding: 12px; }

  /* 移动端列表改为「大图在上、文字在下」，比窄条横排更易读 */
  .post-link { flex-direction: column; gap: 10px; }
  .post-thumb { flex: none; width: 100%; height: 170px; }

  .article-nav { grid-template-columns: 1fr; }
  .article-nav-item.next { text-align: left; }

  .related-list { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .agent-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .gateway-row { flex-direction: column; }
  .gateway-copy { width: 100%; }
}
