:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --border: #e4e0d8;
  --accent: #9a3b1f;
  --accent-soft: #f6e9e3;
  --code-bg: #f3f0ea;
  --banner-bg: #fff6df;
  --banner-border: #ecd9a6;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514;
    --surface: #1e1c1a;
    --text: #ece8e1;
    --muted: #a39d93;
    --border: #34312d;
    --accent: #e08a68;
    --accent-soft: #3a261d;
    --code-bg: #262320;
    --banner-bg: #2d2717;
    --banner-border: #57492a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #161514;
  --surface: #1e1c1a;
  --text: #ece8e1;
  --muted: #a39d93;
  --border: #34312d;
  --accent: #e08a68;
  --accent-soft: #3a261d;
  --code-bg: #262320;
  --banner-bg: #2d2717;
  --banner-border: #57492a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.75 system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

a { color: var(--accent); text-underline-offset: 2px; }

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }

.main-nav { display: flex; gap: 4px 14px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a { color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 15px; padding: 2px 0; }
.main-nav a:hover { color: var(--text); }
.main-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

.layout { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
.layout.with-toc { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 40px; }
main { min-width: 0; max-width: 860px; }

.toc { position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 96px); overflow-y: auto; font-size: 14px; }
.toc p { margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li { margin: 0; }
.toc li a { display: block; padding: 3px 0 3px 12px; color: var(--muted); text-decoration: none; line-height: 1.5; }
.toc li.d3 a { padding-left: 24px; font-size: 13px; }
.toc li a:hover { color: var(--text); }
.toc code { font-size: 12px; }

@media (max-width: 960px) {
  .layout.with-toc { display: block; }
  .toc { display: none; }
}

h1, h2, h3, h4 { line-height: 1.35; scroll-margin-top: 72px; }
h1 { font-size: 28px; margin: 8px 0 20px; }
h2 { font-size: 22px; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
h3 { font-size: 18px; margin: 28px 0 8px; }
.anchor { float: left; margin-left: -1em; width: 1em; color: var(--muted); text-decoration: none; opacity: 0; }
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }
h1 .anchor { display: none; }

p, ul, ol { margin: 0 0 14px; }
li { margin: 2px 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
blockquote { margin: 0 0 14px; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; }
blockquote p:last-child { margin-bottom: 0; }

code { font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace; font-size: 0.88em; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--code-bg); padding: 14px 16px; border-radius: 8px; overflow-x: auto; line-height: 1.55; font-size: 14px; }
pre code { background: none; padding: 0; font-size: inherit; }
:not(pre) > code { overflow-wrap: anywhere; }
main { overflow-wrap: break-word; }

table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 0 0 16px; font-size: 15px; }
th, td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
th { background: var(--code-bg); white-space: nowrap; }

.banner { background: var(--banner-bg); border: 1px solid var(--banner-border); border-radius: 8px; padding: 10px 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 0 0 20px; }

footer { max-width: 1180px; margin: 0 auto; padding: 20px 16px 40px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--border); }

/* Swagger UI 只有浅色主题：接口区域固定浅底，外框跟随站点配色 */
body.swagger .layout { max-width: 1280px; }
body.swagger main { max-width: none; }
.spec-links { color: var(--muted); font-size: 15px; }
#swagger-ui { background: #ffffff; color: #3b4151; border-radius: 8px; padding: 4px 4px 16px; margin-top: 16px; }
#swagger-ui .loading { padding: 16px; margin: 0; }
#swagger-ui .swagger-ui .info { margin: 20px 0; }
#swagger-ui .swagger-ui .scheme-container { box-shadow: none; padding: 12px 0; }
