/* ================================================================
   泽境 Cergin — 统一设计系统
   基准来源：index.html（首页）品牌风格
   适用范围：index.html、api.html、ai-sse.html
   ================================================================ */

/* ===== 1. 设计令牌 ===== */
:root {
  /* 主色系 — 来自 index.html 品牌梯度 */
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --primary-soft: #e0ecff;
  --brand-dark: #1e3a5f;
  --brand-mid: #3b73b4;

  /* 背景 */
  --bg: #ffffff;
  --bg-soft: #f7fafd;
  --bg-code: #0f172a;
  --bg-code-soft: #1e293b;

  /* 前景文字 — 复用 index.html 的 rgba 层级 */
  --text: #0f1b2d;
  --text-rich: #1e293b;
  --text-muted: #5b6b82;
  --text-faint: #8a98ad;
  --text-subtle: rgba(30, 58, 95, 0.55);
  --text-ghost: rgba(30, 58, 95, 0.3);

  /* 边框 */
  --border: #e6ecf3;
  --border-strong: #d4dde8;

  /* 语义色 */
  --success: #16a34a;
  --danger: #dc2626;
  --purple: #7c3aed;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --cyan: #0891b2;

  /* 圆角 — 来自 index.html 的递进体系 */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 10px;
  --radius-btn: 28px;
  --radius-avatar: 36px;

  /* 阴影 — 来自 index.html 的蓝色调投影 */
  --shadow-xs: 0 1px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 8px rgba(59, 130, 246, 0.1);
  --shadow-md: 0 4px 16px rgba(37, 99, 235, 0.25);
  --shadow-lg: 0 8px 32px rgba(59, 130, 246, 0.18);
  --shadow-xl: 0 16px 40px rgba(59, 130, 246, 0.25);

  /* 字体 — 来自 index.html 的 font-family */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;

  /* 布局 */
  --topbar-h: 56px;
  --sidebar-w: 260px;
}

/* ===== 2. 全局重置 & 基础 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 3. 顶栏（统一版） ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 24px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

/* Logo 区 */
.topbar .logo {
  display: flex; align-items: center; gap: 10px;
  color: var(--text);
  text-decoration: none;
}
.topbar .logo img {
  width: 28px; height: 28px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}
.topbar .logo .name {
  letter-spacing: 2px;
  font-size: 15px;
  font-weight: 600;
}
.topbar .logo .sub {
  color: var(--text-faint);
  font-size: 12px;
  letter-spacing: 3px;
}

/* 品牌名（纯文字时） */
.topbar .brand {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.topbar .brand span {
  color: var(--text-faint);
  margin-left: 4px;
}

/* 导航链接 */
.topbar nav {
  margin-left: auto;
  display: flex; align-items: center; gap: 4px;
}
.topbar nav a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius-md);
  letter-spacing: 0.5px;
  transition: color 0.15s, background 0.15s;
}
.topbar nav a:hover {
  color: var(--primary);
  background: var(--primary-soft);
  text-decoration: none;
}
.topbar nav a.active {
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 500;
}

/* ===== 4. 侧栏 ===== */
.layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 28px 16px 40px 28px;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
}

.sidebar .menu-group { margin-bottom: 18px; }

.sidebar .menu-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-faint);
  margin: 0 8px 6px;
}

.sidebar .menu-label:first-child { margin-top: 0; }

.sidebar a {
  display: block;
  padding: 5px 10px;
  margin: 1px 0;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  transition: color 0.12s, background 0.12s;
}
.sidebar a:hover {
  background: #eef3fb;
  color: var(--text);
  text-decoration: none;
}
.sidebar a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}

/* ===== 5. 正文排版 ===== */
.content {
  flex: 1;
  min-width: 0;
  padding: 40px 56px 120px;
  max-width: 980px;
}

.content h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
  color: var(--text);
}

.content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 48px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 72px;
  color: var(--text);
}

.content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 32px 0 8px;
  scroll-margin-top: 72px;
  color: var(--text);
}

.content h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 20px 0 6px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.content p {
  color: var(--text);
  margin: 10px 0;
}

.content .lead {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 20px;
}

.content ul, .content ol {
  padding-left: 22px;
  margin: 10px 0;
  color: var(--text);
}

.content li { margin: 4px 0; }

/* 行内代码 */
.content code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: #eef3fb;
  color: var(--brand-dark);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* ===== 6. 代码块（统一深色主题） ===== */
.code-card {
  background: var(--bg-code);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin: 14px 0 20px;
  box-shadow: var(--shadow-xs);
}

.code-head {
  display: flex; align-items: center;
  background: var(--bg-code-soft);
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-head .lang {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #94a3b8;
}

.code-head .copy {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  padding: 3px 10px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-family: var(--font-sans);
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.15s;
}
.code-head .copy:hover { background: rgba(255, 255, 255, 0.08); }

.code-card pre {
  margin: 0;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: #e2e8f0;
  overflow-x: auto;
  white-space: pre;
}

/* 语法高亮 */
.code-card .k  { color: #93c5fd; }          /* keyword */
.code-card .s  { color: #fcd34d; }          /* string */
.code-card .n  { color: #f0abfc; }          /* number/name */
.code-card .c  { color: #64748b; font-style: italic; }  /* comment */
.code-card .t  { color: #5eead4; }          /* type/method */
.code-card .fn { color: #60a5fa; }          /* function */

/* ===== 7. 表格 ===== */
table.params {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 13.5px;
}

table.params thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  background: var(--bg-soft);
}

table.params tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.55;
}

table.params tbody tr:hover { background: var(--bg-soft); }

table.params td:first-child {
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--text);
}

table.params td .type {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11.5px;
  margin-left: 6px;
}

table.params td .req {
  color: #b91c1c;
  font-size: 11px;
  margin-left: 6px;
  font-weight: 600;
}

table.params td .opt {
  color: var(--text-faint);
  font-size: 11px;
  margin-left: 6px;
}

/* 表格内代码 */
table.params code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

/* 表格横向滚动容器 */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-bottom: 20px;
}
.table-wrap .params { margin-bottom: 0; }

/* ===== 8. 提示框 ===== */
.callout {
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  color: var(--brand-dark);
  padding: 12px 16px;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  margin: 16px 0;
  font-size: 13.5px;
  line-height: 1.6;
}
.callout strong { color: var(--primary); }

.callout.warn {
  border-left-color: var(--warn);
  background: var(--warn-soft);
  color: #5a3a08;
}
.callout.warn strong { color: var(--warn); }

/* ===== 9. 徽标 ===== */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.badge-lifecycle { color: var(--purple);   background: #f3eeff; }
.badge-text       { color: var(--primary);  background: var(--primary-soft); }
.badge-output     { color: var(--success);  background: #e0f7e6; }
.badge-tool       { color: var(--danger);   background: #fde8e8; }
.badge-reasoning  { color: #d97706;         background: var(--warn-soft); }
.badge-builtin    { color: var(--cyan);     background: #e0f5fa; }

/* ===== 10. 端点行 ===== */
.endpoint {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 14px;
  margin-bottom: 8px;
}

.method {
  display: inline-block;
  font-weight: 700; font-size: 10px; letter-spacing: 1px;
  padding: 2px 8px; border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-sans);
}

.method.post   { background: var(--primary); }
.method.get    { background: var(--success); }
.method.del    { background: var(--danger); }
.method.stream { background: var(--purple); }

.endpoint .path { color: var(--text); }

/* ===== 11. 页脚 ===== */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-ghost);
  letter-spacing: 1px;
  padding: 24px 0;
}

/* ===== 12. 响应式 ===== */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { display: none; }
  .content { padding: 28px 20px 80px; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .topbar .brand span { display: none; }
}
