:root {
  --bg: #fdfcfd;
  --bg-subtle: #f9f8fb;
  --panel: #f3f1f7;
  --line: #e9e7ee;
  --line-strong: #d9d5e1;
  --text: #211f26;
  --muted: #65636d;
  --faint: #8e8c99;
  --accent: #6d4aa3;
  --accent-soft: #ece6fb;
  --required: #ce2c31;

  --get: #18794e;    --get-bg: #e6f6eb;
  --post: #0d74ce;   --post-bg: #e6f4fe;
  --put: #cc4e00;    --put-bg: #ffefd6;
  --delete: #ce2c31; --delete-bg: #feebec;

  --code-bg: #faf9fc;
  --tok-key: #6d4aa3;
  --tok-str: #18794e;
  --tok-num: #cc4e00;
  --tok-lit: #0d74ce;
  --tok-punct: #8e8c99;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --top: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121113;
    --bg-subtle: #18171b;
    --panel: #1f1d23;
    --line: #2a282f;
    --line-strong: #3a3740;
    --text: #eeeef0;
    --muted: #b5b2bc;
    --faint: #7c7a85;
    --accent: #bbafd3;
    --accent-soft: #2f2939;
    --required: #ff9592;
    --get: #3dd68c;    --get-bg: #132d21;
    --post: #70b8ff;   --post-bg: #0d2847;
    --put: #ffa057;    --put-bg: #331e0b;
    --delete: #ff9592; --delete-bg: #3b1219;
    --code-bg: #18171b;
    --tok-key: #c4b5f4;
    --tok-str: #8ee5b0;
    --tok-num: #ffb381;
    --tok-lit: #9ecbff;
    --tok-punct: #7c7a85;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121113;
  --bg-subtle: #18171b;
  --panel: #1f1d23;
  --line: #2a282f;
  --line-strong: #3a3740;
  --text: #eeeef0;
  --muted: #b5b2bc;
  --faint: #7c7a85;
  --accent: #bbafd3;
  --accent-soft: #2f2939;
  --required: #ff9592;
  --get: #3dd68c;    --get-bg: #132d21;
  --post: #70b8ff;   --post-bg: #0d2847;
  --put: #ffa057;    --put-bg: #331e0b;
  --delete: #ff9592; --delete-bg: #3b1219;
  --code-bg: #18171b;
  --tok-key: #c4b5f4;
  --tok-str: #8ee5b0;
  --tok-num: #ffb381;
  --tok-lit: #9ecbff;
  --tok-punct: #7c7a85;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, pre { font-family: var(--mono); }
:not(pre) > code {
  font-size: 0.86em;
  padding: 0.1em 0.35em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-subtle);
}
button, select, input { font: inherit; color: inherit; }
.muted { color: var(--muted); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20;
  height: var(--top);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.search {
  flex: 1; max-width: 540px; min-width: 0;
  display: flex; align-items: center;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--bg-subtle);
  padding: 0 8px 0 12px;
}
.search input { flex: 1; border: 0; background: none; padding: 7px 0; outline: none; min-width: 0; }
.search kbd {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 6px;
}
.lang, .download {
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--bg-subtle); padding: 6px 8px; font-size: 13px;
}
.download { color: var(--text); white-space: nowrap; }
.download:hover { text-decoration: none; border-color: var(--muted); }
.theme, .menu {
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--bg-subtle); width: 34px; height: 34px; cursor: pointer;
}
.menu { display: none; }
.top .download { margin-left: auto; }

/* Layout */
.layout { display: flex; }
.nav {
  position: sticky; top: var(--top);
  width: 300px; flex: none;
  height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 28px 16px 40px 24px;
  border-right: 1px solid var(--line);
}
.page { flex: 1; min-width: 0; padding: 36px 48px 96px; }

/* Sidebar */
.nav h4 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.nav details { margin: 2px 0; }
.nav summary {
  list-style: none; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; border-radius: 6px; font-size: 14px;
}
.nav summary::-webkit-details-marker { display: none; }
.nav summary::after { content: "\203A"; color: var(--faint); transition: transform .15s; }
.nav details[open] > summary::after { transform: rotate(90deg); }
.nav summary:hover { background: var(--panel); }
.nav ul { list-style: none; margin: 2px 0 8px 12px; padding: 0; }
.nav li a {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 6px 8px; border-radius: 6px;
  color: var(--text); font-size: 14px; line-height: 1.35;
}
.nav li a:hover { background: var(--panel); text-decoration: none; }
.nav li a.active { background: var(--panel); color: var(--accent); font-weight: 500; }
.nav .intro { display: block; padding: 6px 8px; border-radius: 6px; color: var(--text); font-size: 14px; margin-bottom: 8px; }
.nav .intro.active { background: var(--panel); color: var(--accent); }

/* Method badge */
.badge {
  flex: none;
  display: inline-block; min-width: 40px; text-align: center;
  font: 600 10px/18px var(--mono);
  text-transform: uppercase; letter-spacing: 0.02em;
  border-radius: 4px; padding: 0 5px;
}
.badge.get { color: var(--get); background: var(--get-bg); }
.badge.post { color: var(--post); background: var(--post-bg); }
.badge.put { color: var(--put); background: var(--put-bg); }
.badge.delete { color: var(--delete); background: var(--delete-bg); }

/* Operation page */
.op { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 540px); gap: 48px; align-items: start; max-width: 1240px; }
.crumb { font: 500 12px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.crumb::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--muted); margin-right: 10px; }
h1 { font-size: 36px; line-height: 1.2; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 16px; }
h2 { font-size: 22px; font-weight: 500; margin: 48px 0 12px; }
h3 { font-size: 13px; font-weight: 400; color: var(--muted); margin: 0; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.endpoint { display: flex; align-items: center; gap: 10px; font: 14px var(--mono); color: var(--muted); margin: 0 0 16px; word-break: break-all; }
.lead { color: var(--muted); }

/* Fields */
.fields { list-style: none; margin: 0 0 8px; padding: 0; }
.field { padding: 16px 0; border-bottom: 1px solid var(--line); }
.field-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.field-name { font: 600 14px var(--mono); }
.field-type { font-size: 12px; color: var(--muted); }
.field-req { font-size: 12px; color: var(--required); }
.field-opt { font-size: 12px; color: var(--faint); }
.field p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.field-desc p:first-child { margin-top: 6px; }
.field-rules { font: 12px var(--mono); color: var(--faint); margin-top: 4px; }
.field details { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; }
.field details > summary { cursor: pointer; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.field details > .fields { padding: 0 14px; }
.field details > .fields > .field:last-child { border-bottom: 0; }

/* Code panels */
.aside { position: sticky; top: calc(var(--top) + 24px); display: grid; gap: 20px; }
.card { border: 1px solid var(--line-strong); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font: 12px var(--mono); color: var(--muted);
}
.card-head .path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-head .status { font-weight: 600; }
.card-head .status.ok { color: var(--get); }
.card-head .status.err { color: var(--delete); }
.card-head button.copy {
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--bg); padding: 2px 8px; font-size: 12px; cursor: pointer;
}
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button {
  border: 1px solid transparent; border-radius: 6px; background: none;
  padding: 2px 8px; font: 12px var(--mono); color: var(--muted); cursor: pointer;
}
.tabs button[aria-selected="true"] { border-color: var(--line-strong); background: var(--bg); color: var(--text); }
pre.code {
  margin: 0; padding: 14px 0; max-height: 460px; overflow: auto;
  font-size: 12.5px; line-height: 1.6; counter-reset: ln;
}
pre.code .ln { display: block; padding: 0 16px 0 0; white-space: pre; }
pre.code .ln::before {
  counter-increment: ln; content: counter(ln);
  display: inline-block; width: 40px; padding-right: 14px; text-align: right;
  color: var(--faint); user-select: none;
}
.k { color: var(--tok-key); }
.s { color: var(--tok-str); }
.n { color: var(--tok-num); }
.l { color: var(--tok-lit); }
.p { color: var(--tok-punct); }

/* Intro page */
.prose { max-width: 760px; }
.prose h1 { margin-bottom: 24px; }
.prose h2 { margin-top: 40px; }
.prose pre { background: var(--code-bg); border: 1px solid var(--line-strong); border-radius: 10px; padding: 14px 16px; overflow: auto; font-size: 13px; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line-strong); }

@media (max-width: 1100px) {
  .op { grid-template-columns: minmax(0, 1fr); }
  .aside { position: static; }
}
@media (max-width: 800px) {
  .top { padding: 0 16px; gap: 10px; }
  .menu { display: block; }
  .nav {
    position: fixed; left: 0; top: var(--top); z-index: 10;
    background: var(--bg); width: 100%;
    display: none;
  }
  body.nav-open .nav { display: block; }
  .page { padding: 24px 16px 64px; }
  h1 { font-size: 28px; }
}
