/* entserver docs — neutral surface, blue accent, code as the hero. */

:root {
  --sidebar-w: 300px;
  --toc-w: 248px;
  --header-h: 64px;
  --measure: 50rem;          /* wider column */

  --bg:            #f5f5f5;
  --surface:       #ffffff;
  --surface-2:     #fafafa;
  --text:          #0a0a0a;
  --muted:         #737373;
  --faint:         #a3a3a3;
  --border:        #e5e5e5;
  --border-strong: #d4d4d4;
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-soft:   rgba(37, 99, 235, .10);
  --code-bg:       #f1f1f1;
  --code-border:   #e5e5e5;
  --inline-bg:     #ebebeb;
  --sel:           rgba(37, 99, 235, .18);

  --ok:   #15803d;
  --warn: #b45309;
  --err:  #b91c1c;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-sm: 6px;
  --r:    8px;
  --r-lg: 12px;
}

:root[data-theme="dark"] {
  --bg:            #0a0a0a;
  --surface:       #141414;
  --surface-2:     #171717;
  --text:          #fafafa;
  --muted:         #a3a3a3;
  --faint:         #737373;
  --border:        #262626;
  --border-strong: #363636;
  --accent:        #60a5fa;
  --accent-hover:  #93c5fd;
  --accent-soft:   rgba(96, 165, 250, .14);
  --code-bg:       #121212;
  --code-border:   #262626;
  --inline-bg:     #262626;
  --sel:           rgba(96, 165, 250, .24);

  --ok:   #4ade80;
  --warn: #fbbf24;
  --err:  #f87171;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.72;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--sel); }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ------------------------------------------------------------------ header */

header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  width: calc(var(--sidebar-w) - 20px);
  flex: none;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-logo {
  width: 36px; height: 36px;
  flex: none;
  border-radius: var(--r);
  object-fit: cover;
  display: block;
}
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -.015em; }

.search-wrap { position: relative; flex: 1; max-width: 420px; }
#search {
  width: 100%;
  height: 34px;
  padding: 0 34px 0 34px;
  font: 400 14px var(--sans);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
#search::placeholder { color: var(--faint); }
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-icon {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--faint);
  pointer-events: none;
}
.search-wrap kbd {
  position: absolute; right: 9px; top: 50%;
  transform: translateY(-50%);
  font: 400 11px var(--mono);
  color: var(--faint);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  pointer-events: none;
}

.header-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.header-link {
  font-size: 14px;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--r-sm);
}
.header-link:hover { color: var(--text); background: var(--surface); text-decoration: none; }

.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .14s, color .14s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
#menu-btn { display: none; }

/* --------------------------------------------------------- search results */

#search-results {
  position: absolute;
  top: 42px; left: 0; right: 0;
  max-height: 64vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .14);
  display: none;
  z-index: 50;
}
#search-results.show { display: block; }
.sr-item { display: block; padding: 8px 11px; border-radius: var(--r); color: var(--text); }
.sr-item:hover, .sr-item.active { background: var(--accent-soft); text-decoration: none; }
.sr-group { font-size: 11.5px; color: var(--muted); }
.sr-title { font-size: 14px; font-weight: 550; margin: 1px 0 2px; }
.sr-snippet { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.sr-snippet mark { background: var(--accent-soft); color: var(--text); font-weight: 600; border-radius: 2px; }
.sr-empty { padding: 18px; text-align: center; font-size: 14px; color: var(--muted); }

/* ------------------------------------------------------------------ layout */

.layout { display: flex; padding-top: var(--header-h); }

#sidebar {
  position: fixed;
  top: var(--header-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  padding: 20px 12px 48px 20px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 30;
}

.nav-group + .nav-group { margin-top: 22px; }
.nav-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 0 10px;
  margin-bottom: 5px;
}
#nav a {
  display: block;
  padding: 5px 10px;
  margin: 1px 0;
  font-size: 14px;
  color: var(--muted);
  border-radius: var(--r-sm);
  transition: background .12s, color .12s;
}
#nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
#nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }

main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  margin-right: var(--toc-w);
  display: flex;
  justify-content: center;
  padding: 0 44px;
}
.content { width: 100%; max-width: var(--measure); padding: 44px 0 96px; }

#toc {
  position: fixed;
  top: var(--header-h); right: 0; bottom: 0;
  width: var(--toc-w);
  overflow-y: auto;
  padding: 48px 22px 48px 6px;
}
.toc-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
#toc a {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  border-left: 2px solid var(--border);
}
#toc a:hover { color: var(--text); text-decoration: none; }
#toc a.active { color: var(--accent); border-left-color: var(--accent); }
#toc a.lvl-3 { padding-left: 24px; }

/* ----------------------------------------------------------------- article */

.doc-section { scroll-margin-top: 80px; }
.doc-section > h2:first-child { margin-top: 0; padding-top: 0; }
.doc-section + .doc-section {
  margin-top: 46px;
  padding-top: 46px;
  border-top: 1px solid var(--border);
}

.eyebrow {
  font-size: 13px;
  font-weight: 550;
  color: var(--accent);
  margin: 0 0 10px;
}

.content h1 {
  font-size: 38px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -.025em;
  margin: 0 0 14px;
}
.content h2 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.015em;
  margin: 50px 0 16px;
  padding-top: 6px;
  scroll-margin-top: 82px;
}
.content h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 34px 0 12px;
  scroll-margin-top: 82px;
}
.content h2:first-child, .content h1:first-child { margin-top: 0; }

.content p { margin: 15px 0; }
.content ul, .content ol { margin: 15px 0; padding-left: 24px; }
.content li { margin: 6px 0; }
.content li::marker { color: var(--faint); }
.content strong { font-weight: 650; }
.content hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }

.content .lead {
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 8px;
}

/* heading anchor */
.h-anchor {
  margin-left: 8px;
  color: var(--faint);
  font-weight: 400;
  opacity: 0;
  text-decoration: none;
  transition: opacity .12s;
}
.content h2:hover .h-anchor,
.content h3:hover .h-anchor { opacity: 1; }
.h-anchor:hover { color: var(--accent); text-decoration: none; }

/* inline code */
.content :not(pre) > code {
  font: 500 .85em var(--mono);
  background: var(--inline-bg);
  color: var(--text);
  padding: .12em .38em;
  border-radius: var(--r-sm);
  word-break: break-word;
}

/* code blocks */
.content pre {
  position: relative;
  margin: 18px 0;
  padding: 15px 16px;
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--r-lg);
  font-size: 14px;
  line-height: 1.7;
}
.content pre code {
  font-family: var(--mono);
  background: none;
  padding: 0;
  color: var(--text);
  white-space: pre;
}

/* the HTTP request/response block — the hero of the docs */
.content pre.is-http {
  padding-top: 38px;
  background: var(--surface);
  border-color: var(--border-strong);
}
.content pre.is-http::before {
  content: attr(data-label);
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font: 600 11px var(--mono);
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--code-bg);
  border-bottom: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.content pre.is-http .hl-method { color: var(--accent); font-weight: 700; }
.content pre.is-http .hl-ok     { color: var(--ok);  font-weight: 700; }
.content pre.is-http .hl-err    { color: var(--err); font-weight: 700; }

.copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  padding: 3px 10px;
  font: 500 12px var(--sans);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity .14s, color .14s, border-color .14s;
  z-index: 2;
}
.content pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.copy-btn.done { color: var(--ok); border-color: var(--ok); }

/* tables */
.table-scroll {
  margin: 18px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.content table { width: 100%; min-width: 460px; border-collapse: collapse; font-size: 14.5px; }
.content th, .content td {
  text-align: left;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.content th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.content tbody tr:last-child td { border-bottom: none; }
.content td code, .content th code { white-space: nowrap; }

/* blockquote as aside */
.content blockquote {
  margin: 18px 0;
  padding: 12px 16px;
  color: var(--muted);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r) var(--r) 0;
}
.content blockquote p { margin: 4px 0; }

/* ---------------------------------------------------------- related cards */

.related {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.related a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--text);
  transition: border-color .14s, background .14s;
}
.related a:hover { border-color: var(--accent); text-decoration: none; }
.related a.next { text-align: right; align-items: flex-end; }
.related .dir { font-size: 12.5px; color: var(--muted); }
.related .rtitle { font-size: 15px; font-weight: 600; color: var(--accent); }
.related .rdesc { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.related a.empty { visibility: hidden; }

/* ------------------------------------------------------------- scrollbars */

#sidebar::-webkit-scrollbar, #toc::-webkit-scrollbar,
.content pre::-webkit-scrollbar, .table-scroll::-webkit-scrollbar { width: 9px; height: 9px; }
#sidebar::-webkit-scrollbar-thumb, #toc::-webkit-scrollbar-thumb,
.content pre::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 6px;
}

/* ----------------------------------------------------------------- mobile */

#overlay {
  display: none;
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: rgba(0, 0, 0, .4);
  z-index: 25;
}

@media (max-width: 1160px) {
  main { margin-right: 0; }
  #toc { display: none; }
}

@media (max-width: 820px) {
  :root { --header-h: 52px; }
  #menu-btn { display: flex; }
  .brand { width: auto; }
  .header-link { display: none; }
  .search-wrap kbd { display: none; }
  #sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .2);
  }
  body.nav-open #sidebar { transform: translateX(0); }
  body.nav-open #overlay { display: block; }
  main { margin-left: 0; padding: 0 20px; }
  .related { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .search-wrap { max-width: none; }
}
