/* ============================================================
   跨境BotAPI 接入文档 — 样式
   中性科技蓝/灰 · 深浅双主题
   ============================================================ */

:root {
  --accent: #2563eb;
  --accent-soft: #3b82f6;

  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-sunken: #eef1f5;
  --surface: #ffffff;
  --border: #e3e8ef;
  --text: #1a2230;
  --text-2: #4a5568;
  --text-3: #8a94a6;

  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --code-border: #1e293b;
  --tabbar-bg: #1a2336;

  --topbar-h: 56px;
  --sidebar-w: 260px;
  --maxw: 880px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
}

[data-theme="dark"] {
  --accent: #60a5fa;
  --accent-soft: #3b82f6;

  --bg: #0c111b;
  --bg-soft: #121826;
  --bg-sunken: #0a0f18;
  --surface: #141b2b;
  --border: #232c3d;
  --text: #e6ebf2;
  --text-2: #aab4c5;
  --text-3: #6b7689;

  --code-bg: #0a0e17;
  --code-text: #d7dee9;
  --code-border: #1c2538;
  --tabbar-bg: #11192a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

code { font-family: var(--mono); }

/* ===================== 顶栏 ===================== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  height: 100%; max-width: calc(var(--sidebar-w) + var(--maxw) + 80px);
  margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .5px;
}
.brand-name { font-weight: 700; font-size: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 8px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-2); font-size: 17px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--bg-soft); border-color: var(--border); }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }
.only-mobile { display: none; }

/* ===================== 布局 ===================== */
.layout {
  max-width: calc(var(--sidebar-w) + var(--maxw) + 80px);
  margin: 0 auto; padding: 0 20px;
  display: grid; grid-template-columns: var(--sidebar-w) 1fr; gap: 40px;
}

/* ===================== 侧栏 ===================== */
.sidebar {
  position: sticky; top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 24px 8px 40px 0;
}
.toc { display: flex; flex-direction: column; gap: 2px; }
.toc-group {
  margin: 18px 0 6px; padding: 0 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3);
}
.toc-group:first-child { margin-top: 0; }
.toc-link {
  padding: 6px 10px; border-radius: 7px;
  font-size: 14px; color: var(--text-2); text-decoration: none;
  border-left: 2px solid transparent;
  transition: background .12s, color .12s;
}
.toc-link:hover { background: var(--bg-soft); color: var(--text); }
.toc-link.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent); font-weight: 600;
  border-left-color: var(--accent);
}
.sidebar-backdrop { display: none; }

/* ===================== 正文 ===================== */
.content { max-width: var(--maxw); padding: 36px 0 80px; min-width: 0; }
.sec { scroll-margin-top: calc(var(--topbar-h) + 16px); margin-bottom: 56px; }

.eyebrow {
  color: var(--accent); font-weight: 700; font-size: 13px;
  letter-spacing: .04em; margin: 0 0 8px;
}
h1 { font-size: 32px; line-height: 1.25; font-weight: 800; margin: 0 0 16px; letter-spacing: -.01em; }
h2 {
  font-size: 23px; font-weight: 750; margin: 0 0 14px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
h3 { font-size: 17px; font-weight: 700; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h3.sub-h3 { margin-top: 44px; padding-top: 28px; border-top: 1px solid var(--border); }
.lead { font-size: 16px; color: var(--text-2); margin: 0 0 18px; }
p { margin: 0 0 14px; color: var(--text-2); }
.content p code, .content li code, h2 code, h3 code, td code {
  font-size: .88em; padding: .12em .4em; border-radius: 5px;
  background: var(--bg-sunken); color: var(--text); border: 1px solid var(--border);
}
.muted { color: var(--text-3); }

/* 列表 */
.bullet, .ordered { margin: 0 0 14px; padding-left: 22px; color: var(--text-2); }
.bullet li, .ordered li { margin: 6px 0; }
.bullet { list-style: disc; }
.ordered { list-style: decimal; }

/* ===================== Callout ===================== */
.callout {
  border-radius: var(--radius); padding: 14px 16px; margin: 16px 0;
  font-size: 14.5px; border: 1px solid var(--border); background: var(--bg-soft);
  border-left: 3px solid var(--text-3);
}
.callout code { background: var(--bg-sunken); }
.callout-info { border-left-color: var(--accent); }
.callout-warn { border-left-color: #d97706; }
[data-theme="dark"] .callout-warn { border-left-color: #f59e0b; }

/* ===================== 信息卡片 ===================== */
.info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px; margin: 16px 0;
}
.info-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.info-label { font-size: 12px; color: var(--text-3); font-weight: 600; margin-bottom: 6px; }
.info-value { font-size: 14px; color: var(--text); word-break: break-all; }
.info-value code { background: var(--bg-sunken); }

/* ===================== 模型卡片 ===================== */
.model-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px; margin: 18px 0;
}
.model-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.model-head { font-weight: 700; font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.model-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.model-tags span {
  font-family: var(--mono); font-size: 12px;
  padding: 3px 8px; border-radius: 6px;
  background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text-2);
}

/* 协议标签 */
.proto-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 2px 9px; border-radius: 999px; color: #fff; white-space: nowrap;
}
.tag-anthropic { background: #c2410c; }
.tag-openai    { background: #0f766e; }
.tag-gemini    { background: #4338ca; }
.tag-video     { background: #7c3aed; }
.tag-tts       { background: #be185d; }

/* ===================== 代码 Tab ===================== */
.code-tabs {
  margin: 16px 0; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--code-border); background: var(--code-bg);
  box-shadow: var(--shadow);
}
.tab-bar {
  display: flex; align-items: stretch; gap: 0; flex-wrap: wrap;
  background: var(--tabbar-bg); border-bottom: 1px solid var(--code-border);
  padding: 0 6px;
}
.tab-btn {
  appearance: none; background: transparent; border: none; cursor: pointer;
  padding: 10px 14px; font-size: 13px; font-family: var(--sans);
  color: #94a3b8; border-bottom: 2px solid transparent; transition: color .12s, border-color .12s;
}
.tab-btn:hover { color: #cbd5e1; }
.tab-btn.active { color: #fff; border-bottom-color: var(--accent); font-weight: 600; }

.code-wrap { position: relative; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel pre {
  margin: 0; padding: 16px 18px; overflow-x: auto;
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  color: var(--code-text);
}
.tab-panel pre code { font-family: var(--mono); white-space: pre; }

/* 复制按钮（由 JS 注入到 .tab-panel） */
.copy-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; font-size: 12px; font-family: var(--sans);
  color: #cbd5e1; background: rgba(148, 163, 184, .14);
  border: 1px solid rgba(148, 163, 184, .25); border-radius: 6px;
  cursor: pointer; opacity: 0; transition: opacity .15s, background .15s;
}
.tab-panel.active:hover .copy-btn,
.copy-btn:focus { opacity: 1; }
.copy-btn:hover { background: rgba(148, 163, 184, .26); color: #fff; }
.copy-btn.copied { color: #6ee7b7; border-color: rgba(110, 231, 183, .4); background: rgba(16, 185, 129, .16); }

/* ===================== 表格 ===================== */
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
thead th {
  text-align: left; background: var(--bg-soft); color: var(--text);
  font-weight: 700; padding: 11px 16px; border-bottom: 1px solid var(--border);
}
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-soft); }

/* ===================== 页脚 ===================== */
.content-footer {
  margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-2);
}
.content-footer p { margin: 2px 0; }

/* ===================== 响应式 ===================== */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 0; }
  .only-mobile { display: inline-grid; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; z-index: 45;
    width: 280px; height: calc(100vh - var(--topbar-h));
    background: var(--bg); border-right: 1px solid var(--border);
    padding: 20px 16px; transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
  .sidebar-backdrop.show {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 44;
    background: rgba(0,0,0,.4);
  }
  .content { padding: 28px 0 60px; }
  h1 { font-size: 27px; }
  h2 { font-size: 21px; }
}
