:root {
  --topbar-height: 68px;
  --sidebar-width: 264px;
  --console-width: 376px;
  --page: #f3f6f4;
  --paper: #ffffff;
  --paper-soft: #e9eeeb;
  --ink: #19231e;
  --muted: #66736c;
  --line: #d5ddd8;
  --line-strong: #becac2;
  --topbar: #122019;
  --topbar-ink: #f2f7f4;
  --nav: #e5ebe7;
  --nav-active: #ffffff;
  --green: #20895a;
  --green-bright: #8ee08c;
  --green-soft: #d8f1e2;
  --blue: #286ea8;
  --blue-soft: #dcecf7;
  --coral: #d85d49;
  --amber: #c99022;
  --console: #101815;
  --console-panel: #17211c;
  --console-line: #2c3932;
  --console-ink: #dce8e1;
  --shadow: 0 16px 38px rgba(15, 32, 23, .15);
}

:root[data-theme="dark"] {
  --page: #111713;
  --paper: #17201b;
  --paper-soft: #202a24;
  --ink: #edf4ef;
  --muted: #9caaa2;
  --line: #303b35;
  --line-strong: #46534c;
  --topbar: #080e0b;
  --nav: #141c18;
  --nav-active: #222d27;
  --green: #62c98e;
  --green-soft: #1b3a29;
  --blue: #77bce8;
  --blue-soft: #203646;
  --coral: #f08370;
  --amber: #e9ba5b;
  --console: #090e0b;
  --console-panel: #121915;
  --console-line: #28332d;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
body.console-open { overflow: hidden; }
button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 80;
  height: var(--topbar-height);
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 520px) minmax(220px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  color: var(--topbar-ink);
  background: var(--topbar);
  border-bottom: 1px solid #26352d;
}
.topbar-brand, .topbar-actions, .brand { display: flex; align-items: center; }
.topbar-brand { gap: 8px; min-width: 0; }
.brand { min-width: 0; gap: 10px; }
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  color: #102017;
  background: var(--green-bright);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
}
.brand-copy { min-width: 0; }
.brand-copy strong, .brand-copy small { display: block; white-space: nowrap; }
.brand-copy strong { font-size: 14px; }
.brand-copy small { margin-top: 2px; color: #9eb0a6; font-size: 9px; text-transform: uppercase; }
.topbar .menu-button { display: none; }
.topbar-actions { justify-content: flex-end; gap: 4px; }
.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}
.icon-button:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .12); }
.environment { display: flex; align-items: center; gap: 7px; margin-right: 8px; color: #b9c7bf; font-size: 10px; text-transform: uppercase; }
.environment i { width: 7px; height: 7px; background: var(--green-bright); border-radius: 50%; box-shadow: 0 0 0 3px rgba(142, 224, 140, .12); }
.search-box {
  height: 40px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: #9eb0a6;
  background: #1a2a22;
  border: 1px solid #31443a;
  border-radius: 6px;
}
.search-box:focus-within { border-color: #6cae83; }
.search-box svg { width: 16px; height: 16px; }
.search-box input { width: 100%; min-width: 0; padding: 0; color: #f4f8f5; background: transparent; border: 0; outline: 0; }
.search-box input::placeholder { color: #84978d; }
.search-hint { padding-left: 8px; color: #788b81; border-left: 1px solid #31443a; font-size: 9px; white-space: nowrap; }

.workspace { min-height: 100vh; padding-top: var(--topbar-height); }
.sidebar {
  position: fixed;
  inset: var(--topbar-height) auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 14px;
  background: var(--nav);
  border-right: 1px solid var(--line-strong);
}
.catalogue-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 8px 16px; border-bottom: 1px solid var(--line-strong); }
.catalogue-heading > div { display: flex; align-items: center; gap: 9px; }
.catalogue-heading > div > span { width: 28px; height: 22px; display: grid; place-items: center; color: #fff; background: var(--blue); border-radius: 4px; font-size: 9px; font-weight: 900; }
.catalogue-heading strong { font-size: 13px; }
.catalogue-heading > span { color: var(--muted); font-family: Consolas, monospace; font-size: 10px; }
.endpoint-nav { min-height: 0; flex: 1; overflow-y: auto; padding: 14px 2px 20px; scrollbar-width: thin; }
.nav-group { margin-bottom: 19px; }
.nav-group-title { margin: 0 0 6px; padding: 0 8px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.nav-endpoint {
  position: relative;
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
  padding: 6px 8px 6px 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
}
.nav-endpoint::before { content: ""; position: absolute; inset: 7px auto 7px 0; width: 3px; background: transparent; border-radius: 0 2px 2px 0; }
.nav-endpoint span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.nav-endpoint:hover { color: var(--ink); background: color-mix(in srgb, var(--paper) 55%, transparent); }
.nav-endpoint.active { color: var(--ink); background: var(--nav-active); border-color: var(--line); box-shadow: 0 4px 12px rgba(25, 46, 34, .06); font-weight: 750; }
.nav-endpoint.active::before { background: var(--green); }
.mini-method { color: var(--green); font-family: Consolas, monospace; font-size: 8px; font-weight: 900; }
.nav-empty { padding: 22px 8px; color: var(--muted); font-size: 12px; }
.sidebar-foot { display: flex; align-items: center; gap: 9px; padding: 14px 8px 2px; border-top: 1px solid var(--line-strong); }
.status-dot { width: 8px; height: 8px; flex: 0 0 8px; background: var(--green); border-radius: 50%; }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 10px; }
.sidebar-foot small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.sidebar-backdrop, .console-backdrop { display: none; }

.doc-main {
  min-height: calc(100vh - var(--topbar-height));
  margin-left: var(--sidebar-width);
  margin-right: var(--console-width);
  padding: 46px 44px 0;
  background-color: var(--paper);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: -1px -1px;
}
.doc-main > * { max-width: 860px; margin-left: auto; margin-right: auto; }
.doc-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; padding: 0 0 32px; background: var(--paper); }
.hero-copy { min-width: 0; }
.endpoint-kicker { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.method { padding: 5px 7px; color: #0f6c42; background: var(--green-soft); border: 1px solid color-mix(in srgb, var(--green) 28%, transparent); border-radius: 4px; font-family: Consolas, monospace; font-size: 10px; font-weight: 900; }
.endpoint-index { padding-left: 9px; border-left: 1px solid var(--line); font-family: Consolas, monospace; }
h1 { margin: 0; font-size: 32px; line-height: 1.18; }
.endpoint-description { max-width: 690px; margin: 15px 0 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.copy-button { height: 36px; display: flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 0 11px; color: var(--ink); background: var(--paper-soft); border: 1px solid var(--line-strong); border-radius: 6px; cursor: pointer; }
.copy-button:hover { border-color: var(--green); }
.copy-button svg { width: 14px; height: 14px; }
.copy-button span { font-size: 11px; }

.endpoint-bar { display: grid; grid-template-columns: 145px minmax(0, 1fr) auto; min-height: 82px; overflow: hidden; color: var(--console-ink); background: var(--topbar); border: 1px solid #26372e; border-radius: 7px; box-shadow: var(--shadow); }
.address-label { display: flex; align-items: center; gap: 8px; padding: 0 18px; color: #9fb0a7; background: #192a21; border-right: 1px solid #304139; font-size: 9px; font-weight: 800; }
.address-label svg { width: 15px; height: 15px; color: var(--green-bright); }
.address-value { min-width: 0; display: flex; align-items: center; gap: 0; overflow: hidden; padding: 0 18px; font-family: Consolas, monospace; font-size: 12px; white-space: nowrap; }
.base-url { color: #83958b; }
.endpoint-bar code { min-width: 0; overflow: hidden; color: #f2f7f4; text-overflow: ellipsis; }
.run-shortcut { align-self: center; height: 38px; display: flex; align-items: center; gap: 7px; margin-right: 12px; padding: 0 13px; color: #102017; background: var(--green-bright); border: 0; border-radius: 5px; cursor: pointer; font-size: 11px; font-weight: 800; }
.run-shortcut:hover { background: #a0eaa0; }
.run-shortcut svg { width: 15px; height: 15px; }
.endpoint-meta { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; padding: 0 2px 28px; color: var(--muted); background: var(--paper); border-bottom: 1px solid var(--line); font-size: 10px; }
.endpoint-meta span { display: flex; align-items: center; gap: 5px; }
.endpoint-meta svg { width: 13px; height: 13px; color: var(--blue); }

.doc-section { margin-top: 46px; padding: 0 0 4px; background: var(--paper); scroll-margin-top: 86px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-title-row > div { display: flex; align-items: center; gap: 11px; }
.section-number { width: 26px; height: 26px; display: grid; place-items: center; color: var(--paper); background: var(--ink); border-radius: 4px; font-family: Consolas, monospace; font-size: 10px; font-weight: 900; }
h2 { margin: 0; font-size: 19px; }
.section-caption { color: var(--muted); font-family: Consolas, monospace; font-size: 9px; }
.parameter-table { border-top: 2px solid var(--ink); }
.parameter-head, .parameter-row { display: grid; grid-template-columns: minmax(125px, .75fr) 92px 68px minmax(210px, 1.45fr); align-items: center; gap: 14px; padding: 0 12px; }
.parameter-head { min-height: 37px; color: var(--muted); border-bottom: 1px solid var(--line-strong); font-size: 9px; font-weight: 800; }
.parameter-row { min-height: 62px; border-bottom: 1px solid var(--line); }
.param-name { color: var(--blue); font-family: Consolas, monospace; font-size: 12px; font-weight: 800; }
.param-type { color: var(--muted); font-family: Consolas, monospace; font-size: 10px; }
.required { width: fit-content; color: var(--coral); font-size: 9px; font-weight: 800; }
.optional { color: var(--muted); font-size: 9px; }
.param-desc { color: var(--muted); font-size: 11px; line-height: 1.55; }
.no-params { min-height: 68px; display: flex; align-items: center; gap: 9px; padding: 0 12px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 11px; }
.no-params svg { width: 16px; height: 16px; color: var(--green); }

.success-status { display: flex; align-items: center; gap: 7px; color: var(--green); font-family: Consolas, monospace; font-size: 10px; font-weight: 800; }
.success-status i { width: 8px; height: 8px; background: var(--green); border-radius: 50%; }
.response-grid { display: flex; flex-direction: column; gap: 26px; }
.example-panel { order: -1; min-width: 0; overflow: hidden; background: var(--console); border: 1px solid var(--console-line); border-radius: 7px; }
.schema-panel { min-width: 0; border-top: 2px solid var(--ink); }
.panel-label { min-height: 39px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; color: var(--muted); border-bottom: 1px solid var(--line-strong); font-size: 9px; font-weight: 800; }
.panel-label > span:last-child { font-family: Consolas, monospace; font-size: 8px; }
.example-panel .panel-label { color: #aab9b1; background: var(--console-panel); border-bottom-color: var(--console-line); }
.example-panel .icon-button { width: 32px; height: 32px; color: #aab9b1; }
.schema-row { min-height: 50px; display: grid; grid-template-columns: minmax(150px, .8fr) 105px minmax(190px, 1fr); align-items: center; gap: 12px; padding: 7px 12px; border-bottom: 1px solid var(--line); }
.schema-row:nth-child(even) { background: var(--paper-soft); }
.schema-name { min-width: 0; overflow: hidden; color: var(--blue); text-overflow: ellipsis; white-space: nowrap; font-family: Consolas, monospace; font-size: 11px; font-weight: 800; }
.schema-type { color: var(--amber); font-family: Consolas, monospace; font-size: 10px; }
.schema-desc { color: var(--muted); font-size: 10px; line-height: 1.5; }
pre { margin: 0; }
.example-panel pre { max-height: 520px; overflow: auto; padding: 17px; }
code { font-family: Consolas, "SFMono-Regular", monospace; }
pre code { color: var(--console-ink); font-size: 11px; line-height: 1.65; white-space: pre; }
.json-key { color: #77bce8; }
.json-string { color: #8fd3a5; }
.json-number { color: #efb46c; }
.json-boolean { color: #d7a0e8; }
.json-null { color: #87948d; }

.debug-panel {
  position: fixed;
  inset: var(--topbar-height) 0 0 auto;
  z-index: 50;
  width: var(--console-width);
  overflow-y: auto;
  padding: 26px 20px;
  color: var(--console-ink);
  background: var(--console);
  border-left: 1px solid var(--console-line);
}
.debug-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.debug-head > div { min-width: 0; }
.live-label { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; color: #8fa198; font-family: Consolas, monospace; font-size: 9px; font-weight: 800; }
.live-label i { width: 7px; height: 7px; background: var(--green-bright); border-radius: 50%; box-shadow: 0 0 0 4px rgba(142, 224, 140, .1); }
.debug-head h2 { color: #f2f7f4; font-size: 18px; }
.close-debug { display: none; color: #9eafa6; }
.debug-address { min-height: 44px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 9px; margin-bottom: 20px; padding: 0 10px; background: var(--console-panel); border: 1px solid var(--console-line); border-radius: 5px; }
.debug-address span { color: var(--green-bright); font-family: Consolas, monospace; font-size: 9px; font-weight: 900; }
.debug-address code { overflow: hidden; color: #bdcbc3; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.debug-inputs { display: grid; grid-template-columns: 1fr; gap: 12px; }
.debug-field label { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; color: #aebcb4; font-family: Consolas, monospace; font-size: 9px; font-weight: 700; }
.debug-field label em { color: #ff907b; font-style: normal; }
.debug-field input { width: 100%; height: 38px; padding: 0 10px; color: #edf4ef; background: var(--console-panel); border: 1px solid var(--console-line); border-radius: 5px; outline: 0; }
.debug-field input:focus { border-color: #72bd8a; box-shadow: 0 0 0 3px rgba(114, 189, 138, .1); }
.debug-panel .no-params { min-height: 54px; padding: 0 10px; color: #91a198; border: 1px solid var(--console-line); border-radius: 5px; }
.send-button { width: 100%; height: 40px; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; color: #102017; background: var(--green-bright); border: 0; border-radius: 5px; cursor: pointer; font-size: 11px; font-weight: 850; }
.send-button:hover { background: #a0eaa0; }
.send-button:disabled { opacity: .58; cursor: wait; }
.send-button svg { width: 14px; height: 14px; }
.debug-response { min-height: 132px; margin-top: 18px; overflow: hidden; background: #080d0a; border: 1px solid var(--console-line); border-radius: 5px; }
.response-placeholder { min-height: 130px; display: flex; align-items: center; justify-content: center; gap: 8px; color: #708078; font-size: 10px; }
.response-placeholder svg { width: 16px; height: 16px; }
.live-response-head { min-height: 38px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px 11px; padding: 7px 10px; color: #8b9c93; border-bottom: 1px solid var(--console-line); font-size: 9px; }
.live-response-head span:last-child { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-response-head .ok { color: #78d89b; }
.live-response-head .fail { color: #ff8d79; }
.debug-response pre { max-height: 440px; overflow: auto; padding: 13px; }

.docs-footer { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 62px; color: var(--muted); background: var(--paper); border-top: 1px solid var(--line); font-size: 10px; }
.docs-footer a { display: flex; align-items: center; gap: 6px; }
.docs-footer svg { width: 13px; height: 13px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(340px, calc(100vw - 36px)); padding: 10px 13px; color: #fff; background: #203128; border-radius: 5px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease; font-size: 11px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #93463a; }

@media (max-width: 1320px) {
  .topbar { grid-template-columns: minmax(200px, 1fr) minmax(260px, 460px) minmax(190px, 1fr); gap: 14px; }
  .doc-main { margin-right: 0; padding-left: 38px; padding-right: 38px; }
  .debug-panel { z-index: 72; transform: translateX(100%); box-shadow: var(--shadow); transition: transform .2s ease; }
  .debug-panel.open { transform: translateX(0); }
  .close-debug { display: grid; }
  .console-backdrop { position: fixed; inset: var(--topbar-height) 0 0; z-index: 71; background: rgba(4, 9, 6, .46); }
  .console-backdrop.show { display: block; }
}

@media (max-width: 940px) {
  :root { --sidebar-width: 286px; }
  .topbar { grid-template-columns: minmax(150px, 1fr) minmax(210px, 360px) auto; padding: 0 12px; }
  .topbar .menu-button { display: grid; color: var(--topbar-ink); }
  .environment { display: none; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: var(--topbar-height) 0 0; z-index: 39; background: rgba(4, 9, 6, .46); }
  .sidebar-backdrop.show { display: block; }
  .doc-main { margin-left: 0; padding: 38px 26px 0; }
  .address-label { display: none; }
  .endpoint-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .debug-panel { width: min(420px, 100%); }
}

@media (max-width: 600px) {
  :root { --topbar-height: 112px; }
  .topbar { height: var(--topbar-height); grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 56px 44px; gap: 0 10px; padding: 0 12px 10px; }
  .topbar-brand { grid-column: 1; grid-row: 1; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .search-box { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .brand-copy small { display: none; }
  .topbar-actions .icon-button:first-of-type { display: none; }
  .doc-main { padding: 30px 15px 0; }
  .doc-hero { gap: 14px; padding-bottom: 26px; }
  h1 { font-size: 28px; }
  .endpoint-description { font-size: 12px; }
  .copy-button { width: 36px; padding: 0; justify-content: center; }
  .copy-button span { display: none; }
  .endpoint-bar { min-height: 68px; }
  .address-value { padding: 0 12px; font-size: 10px; }
  .base-url { display: none; }
  .run-shortcut { width: 36px; padding: 0; justify-content: center; }
  .run-shortcut span { display: none; }
  .doc-section { margin-top: 38px; }
  .parameter-head { display: none; }
  .parameter-row { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; padding: 12px 8px; }
  .param-name { grid-column: 1; grid-row: 1; }
  .param-type { grid-column: 2; grid-row: 1; }
  .required, .optional { grid-column: 1; grid-row: 2; }
  .param-desc { grid-column: 1 / -1; grid-row: 3; }
  .schema-row { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; padding: 10px 8px; }
  .schema-name { grid-column: 1; grid-row: 1; }
  .schema-type { grid-column: 2; grid-row: 1; }
  .schema-desc { grid-column: 1 / -1; grid-row: 2; }
  .example-panel pre { max-height: 420px; }
  .debug-panel { inset: auto 0 0; width: 100%; max-height: 78vh; padding: 20px 16px; border-top: 1px solid var(--console-line); border-left: 0; transform: translateY(100%); }
  .debug-panel.open { transform: translateY(0); }
  .console-backdrop { inset: var(--topbar-height) 0 0; }
  .docs-footer { margin-top: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
