:root {
  color-scheme: light;
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f6fb;
  --text: #111827;
  --muted: #4b5563;
  --faint: #9ca3af;
  --border: #e5e7eb;
  --primary: #1e54e0;
  --primary-strong: #1342c2;
  --primary-soft: #e8f3ff;
  --blue-soft: #eaf2ff;
  --blue: #2266b8;
  --amber-soft: #fff3d6;
  --amber: #8a5a00;
  --danger-soft: #ffe9e7;
  --code-bg: #0f172a;
  --code-text: #e5edf8;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  --sidebar-width: 272px;
  --topbar-height: 60px;
}

.dark {
  color-scheme: dark;
  --bg: #0b0c10;
  --surface: #12141a;
  --surface-2: #1b1e26;
  --text: #ffffff;
  --muted: #9ca3af;
  --faint: #64748b;
  --border: #334155;
  --primary: #4080ff;
  --primary-strong: #6aa1ff;
  --primary-soft: rgba(30, 84, 224, 0.16);
  --blue-soft: #14233c;
  --blue: #8db8ff;
  --amber-soft: #352610;
  --amber: #ffc766;
  --danger-soft: #3b1d1b;
  --code-bg: #050816;
  --code-text: #e5edf8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.boot-loader {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(30, 84, 224, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 12px;
  overflow: hidden;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 4px 8px 12px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.brand-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: contain;
}

.brand-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-text strong {
  font-size: 14px;
  line-height: 1.2;
}

.brand-text span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 16px;
  overflow-y: auto;
  padding-right: 2px;
}

.nav-section {
  display: grid;
  gap: 4px;
}

.nav-section-title {
  margin: 0 0 4px;
  padding: 0 10px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-link {
  min-height: 34px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 9px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
}

.nav-link > .icon,
.nav-link > .platform {
  width: 20px;
  height: 20px;
  justify-self: center;
}

.nav-link > .icon {
  width: 16px;
  height: 16px;
}

.nav-link > .platform img {
  width: 16px;
  height: 16px;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 500;
}

.nav-link span {
  min-width: 0;
  justify-self: start;
  text-align: left;
  overflow-wrap: anywhere;
}

.sidebar-footer {
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.footer-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  align-items: center;
  gap: 6px;
}

.theme-toggle {
  width: 100%;
}

.language-toggle {
  width: 68px;
  grid-template-columns: 16px minmax(0, auto);
  column-gap: 5px;
  justify-items: center;
  padding-left: 8px;
  padding-right: 8px;
  font-weight: 600;
}

.language-toggle .icon {
  width: 16px;
  height: 16px;
}

.language-toggle .language-icon {
  fill: currentColor;
  stroke: none;
}

.language-toggle span {
  justify-self: center;
  text-align: center;
}

.tag {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 3px 6px;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.platform {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 0;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  background: transparent;
}

.platform-openai {
  color: #111827;
}

.platform img {
  width: 15px;
  height: 15px;
  display: block;
  object-fit: contain;
}

.platform-anthropic {
  color: #67523b;
}

.platform-gemini {
  color: #255ab7;
}

.platform-opencode {
  color: #6847b8;
}

.platform-deepseek {
  color: #2563eb;
  font-size: 8px;
}

.platform-zhipuai {
  color: #7c3aed;
  font-size: 8px;
}

.platform-moonshot {
  color: #0f766e;
  font-size: 8px;
}

.platform-seedance {
  color: #dc2626;
  font-size: 8px;
}

.dark .platform-openai {
  color: #ffffff;
}

.dark .platform-openai img {
  filter: invert(1);
}

.dark .platform-anthropic {
  color: #d8c0a1;
}

.dark .platform-gemini {
  color: #9dbfff;
}

.dark .platform-opencode {
  color: #c2aaff;
}

.dark .platform-deepseek {
  color: #93c5fd;
}

.dark .platform-zhipuai {
  color: #c4b5fd;
}

.dark .platform-moonshot {
  color: #5eead4;
}

.dark .platform-seedance {
  color: #fca5a5;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  padding: 0 28px;
}

.topbar-title {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}

.mobile-menu-button {
  display: none;
}

.content-shell {
  display: grid;
  grid-template-columns: minmax(0, 48rem) 14rem;
  gap: 2.5rem;
  width: min(64rem, calc(100% - 3rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.content {
  min-width: 0;
}

.gateway-card {
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.gateway-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-bottom: 0.75rem;
}

.gateway-card-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.gateway-card-title .icon {
  width: 16px;
  height: 16px;
}

.gateway-card-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1rem;
}

.gateway-node {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary-soft);
  padding: 0.75rem 0.875rem;
  box-shadow: 0 0 0 1px var(--primary);
}

.gateway-node-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gateway-radio {
  width: 14px;
  height: 14px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: var(--surface);
}

.gateway-radio::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: inherit;
  background: var(--primary);
}

.gateway-node-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.gateway-node code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 22px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
}

.page-header p {
  max-width: 44rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.docs-section {
  scroll-margin-top: 5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
}

.content > .endpoint,
.content > .callout,
.content > .tabs,
.content > .code-block,
.content > .table-wrap,
.content > .card-grid {
  margin-bottom: 1rem;
}

.docs-section h2,
.docs-section h3 {
  margin: 0 0 1rem;
  line-height: 1.4;
  font-weight: 600;
}

.docs-section h2 {
  font-size: 20px;
}

.docs-section h3 {
  font-size: 16px;
}

.prose {
  display: grid;
  gap: 1rem;
  color: var(--text);
}

.prose p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.625;
}

.prose ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.625;
}

.prose li + li {
  margin-top: 6px;
}

.inline-code {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  padding: 1px 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
}

.code-block .inline-code {
  border-color: rgba(148, 163, 184, 0.38);
  background: rgba(148, 163, 184, 0.16);
  color: var(--code-text);
  font-weight: 400;
}

.endpoint {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.75rem 0.875rem;
  box-shadow: var(--shadow);
}

.endpoint code {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.method {
  flex: 0 0 auto;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  padding: 5px 7px;
  font-size: 12px;
  font-weight: 800;
}

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0.75rem 0.875rem;
  font-size: 14px;
  line-height: 1.625;
}

.callout-warning {
  border-left-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
}

.requirements {
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.75rem 0.875rem;
}

.requirements-label {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.requirements ul {
  margin: 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.action-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: var(--shadow);
}

.action-button:hover {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
}

.action-button .icon {
  width: 15px;
  height: 15px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0.875rem;
  text-align: left;
  vertical-align: top;
  line-height: 1.65;
}

th {
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}

td {
  color: var(--muted);
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.copyable-model {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 100%;
}

.copyable-model .model-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.model-copy-button {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  border-color: transparent;
  border-radius: 6px;
  background: transparent;
}

.model-copy-button .icon {
  width: 14px;
  height: 14px;
}

.model-copy-button:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.model-copy-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.code-block {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid #1e293b;
  border-radius: 8px;
  background: var(--code-bg);
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 10px 8px 14px;
}

.code-title {
  color: #93c5fd;
  font-size: 12px;
  font-weight: 700;
}

.code-block .icon-button {
  width: 30px;
  height: 30px;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #bfdbfe;
}

pre {
  margin: 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 18px 20px;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

pre code {
  color: var(--code-text);
  font-family: "JetBrains Mono", "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Monaco, Consolas, "PingFang SC", "Microsoft YaHei", monospace;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.75;
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
  white-space: pre;
}

.tabs {
  min-width: 0;
  display: grid;
  gap: 0;
}

.tab-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.tab-button {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.tab-button.active {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.example-modes {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.docs-section[hidden],
.toc-link[hidden] {
  display: none !important;
}

.example-modes > .tab-list {
  flex-wrap: wrap;
  padding-bottom: 0;
}

.example-model-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.example-model-select {
  min-width: 0;
  max-width: 100%;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.tab-panel {
  min-width: 0;
  display: none;
}

.tab-panel.active {
  display: block;
}

.code-tabs {
  display: block;
}

.code-tabs .code-head {
  min-height: 42px;
  padding: 0 8px 0 12px;
}

.code-tab-list {
  display: flex;
  min-width: 0;
  align-self: stretch;
  overflow-x: auto;
}

.code-tab-button {
  position: relative;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #94a3b8;
  padding: 0 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.code-tab-button:first-child {
  padding-left: 2px;
}

.code-tab-button:hover {
  color: #dbeafe;
}

.code-tab-button.active {
  color: #e0f2fe;
}

.code-tab-button.active::after {
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: #60a5fa;
  content: "";
}

.code-tab-panel {
  display: none;
  min-width: 0;
}

.code-tab-panel.active {
  display: block;
}

.code-tabs-copy {
  flex: 0 0 auto;
  margin-left: 6px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.doc-card {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.875rem;
  box-shadow: var(--shadow);
}

.doc-card:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  color: var(--primary-strong);
}

.doc-card span {
  font-weight: 600;
  font-size: 14px;
}

.toc {
  position: sticky;
  top: 5rem;
  align-self: start;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  border-left: 1px solid var(--border);
  padding-left: 18px;
}

.toc-title {
  margin: 0 0 0.75rem;
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toc nav {
  display: grid;
  gap: 2px;
}

.toc-link {
  display: block;
  border-left: 2px solid transparent;
  margin-left: -19px;
  padding: 4px 0 4px 17px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.375;
}

.toc-link-sub {
  padding-left: 29px;
  font-size: 12px;
}

.toc-link:hover {
  color: var(--primary-strong);
}

.toc-link.active {
  border-left-color: var(--primary);
  color: var(--primary-strong);
  font-weight: 600;
}

.overlay {
  display: none;
}

@media (max-width: 1080px) {
  .content-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(86vw, var(--sidebar-width));
    transform: translateX(-100%);
    transition: transform 160ms ease;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .overlay {
    position: fixed;
    inset: 0;
    display: none;
    background: rgba(0, 0, 0, 0.46);
    z-index: 30;
  }

  .sidebar-open .overlay {
    display: block;
  }

  .mobile-menu-button {
    display: inline-grid;
  }

  .topbar {
    padding: 0 16px;
  }

  .content-shell {
    width: min(100% - 2rem, 48rem);
    padding-top: 1.75rem;
  }

  .page-header h1 {
    font-size: 28px;
  }
}

@media (max-width: 620px) {
  .page-header h1 {
    font-size: 26px;
  }

  .docs-section h2 {
    font-size: 19px;
  }

  .docs-section h3 {
    font-size: 15px;
  }

  .endpoint {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  pre {
    padding: 16px;
  }

  pre code {
    font-size: 13px;
  }
}
