:root {
  --ink: #07182b;
  --ink-soft: #385066;
  --paper: #f3f7f9;
  --white: #ffffff;
  --line: #cbd8e2;
  --line-strong: #9fb2c2;
  --blue: #1768e5;
  --cyan: #05aaa9;
  --cyan-dark: #007c7d;
  --magenta: #a91d58;
  --green: #147a55;
  --amber: #8b5700;
  --sidebar: 292px;
  --display: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --body: Inter, "Segoe UI", Arial, sans-serif;
  --utility: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--body); letter-spacing: 0; line-height: 1.65; }
a { color: var(--blue); }
button, input { font: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid #f0a51b; outline-offset: 3px; }

.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 8px 12px; color: var(--white); background: var(--ink); transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.docs-header {
  height: 68px;
  position: fixed;
  z-index: 30;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; flex: 0 0 auto; text-decoration: none; }
.brand img { width: 140px; height: auto; display: block; }
.docs-label { margin-left: 18px; padding-left: 18px; border-left: 1px solid var(--line); color: var(--ink-soft); font-size: 0.86rem; font-weight: 700; }
.header-links { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.header-links a, .header-links span { color: var(--ink); font-size: 0.87rem; font-weight: 700; text-decoration: none; }
.header-links a:hover { color: var(--blue); }
.locale-switch { display: flex; align-items: center; gap: 7px; padding-left: 18px; border-left: 1px solid var(--line); }
.locale-switch [aria-current="page"] { color: var(--blue); }
.locale-separator { color: var(--line-strong) !important; }

.menu-toggle { width: 44px; height: 44px; display: none; margin-left: auto; padding: 10px; background: var(--white); border: 1px solid var(--line); border-radius: 6px; }
.menu-toggle span { width: 100%; height: 2px; display: block; margin: 4px 0; background: var(--ink); }

.docs-shell { min-height: 100vh; padding-top: 68px; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }

.sidebar {
  height: calc(100vh - 68px);
  position: sticky;
  top: 68px;
  overflow-y: auto;
  padding: 24px 20px 32px;
  color: #d9e4ed;
  background: var(--ink);
  border-right: 1px solid #223c55;
}

.search-wrap { position: relative; margin-bottom: 22px; }
.search-wrap label { display: block; margin-bottom: 6px; color: #a9bece; font-family: var(--utility); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.search-wrap input { width: 100%; min-height: 42px; padding: 8px 11px; color: var(--white); background: #102a45; border: 1px solid #496178; border-radius: 5px; }
.search-wrap input::placeholder { color: #9fb3c4; }
.search-count { min-height: 18px; margin: 5px 0 0; color: #a9bece; font-size: 0.72rem; }

.side-nav h2 { margin: 20px 10px 7px; color: #7edbd8; font-family: var(--utility); font-size: 0.68rem; letter-spacing: 0; text-transform: uppercase; }
.side-nav ul { margin: 0; padding: 0; list-style: none; }
.side-nav a { display: block; padding: 8px 10px; color: #d9e4ed; border-left: 2px solid transparent; font-size: 0.86rem; line-height: 1.35; text-decoration: none; }
.side-nav a:hover, .side-nav a[aria-current="page"] { color: var(--white); background: #102a45; border-left-color: var(--cyan); }
.sidebar-note { margin: 28px 10px 0; padding-top: 18px; border-top: 1px solid #365069; color: #a9bece; font-size: 0.76rem; line-height: 1.5; }
.sidebar-note strong { display: block; margin-bottom: 4px; color: var(--white); }
.mobile-links { display: none; margin: 22px 10px 0; padding-top: 16px; border-top: 1px solid #365069; }
.mobile-links a { display: block; margin: 8px 0; color: var(--white); font-size: 0.86rem; }

.doc-main { min-width: 0; background: var(--white); }
.doc-content { width: min(1000px, calc(100% - 72px)); min-height: calc(100vh - 134px); margin-inline: auto; padding: 60px 0 92px; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 20px; color: #688096; font-size: 0.8rem; }
.breadcrumbs a { color: inherit; }
.breadcrumbs span::before { content: "/"; margin-right: 7px; color: var(--line-strong); }

.document-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.meta-chip { padding: 4px 8px; color: var(--ink-soft); background: var(--paper); border: 1px solid var(--line); border-radius: 4px; font-family: var(--utility); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; }
.meta-chip.prototype { color: #8e1949; border-color: #d9a4bb; background: #fff3f7; }
.meta-chip.public { color: #075f50; border-color: #9ed7cb; background: #effbf8; }

.doc-intro h1 { max-width: 850px; margin: 0; font-family: var(--display); font-size: 3.65rem; line-height: 1.03; letter-spacing: 0; }
.doc-intro .lead { max-width: 800px; margin: 18px 0 0; color: var(--ink-soft); font-size: 1.16rem; }
.quick-links { margin: 30px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.quick-links a { padding: 8px 12px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 5px; font-size: 0.86rem; font-weight: 700; text-decoration: none; }
.quick-links a:hover { border-color: var(--blue); }

.doc-section { padding: 54px 0 4px; scroll-margin-top: 74px; }
.doc-section[hidden] { display: none; }
.section-kicker { color: var(--cyan-dark); font-family: var(--utility); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; }
.doc-section h2 { margin: 8px 0 16px; padding-bottom: 13px; border-bottom: 1px solid var(--line); font-family: var(--display); font-size: 2.35rem; line-height: 1.12; letter-spacing: 0; }
.doc-section h3 { margin: 32px 0 10px; font-family: var(--display); font-size: 1.28rem; line-height: 1.25; }
.doc-section h4 { margin: 26px 0 8px; font-size: 1rem; }
.doc-section p, .doc-section li { color: var(--ink-soft); }
.doc-section strong { color: var(--ink); }
.doc-section code, .inline-code { padding: 2px 5px; color: #8e1949; background: #fff3f7; border-radius: 3px; font-family: var(--utility); font-size: 0.86em; overflow-wrap: anywhere; }
.doc-section ul { padding-left: 22px; }
.doc-section li + li { margin-top: 7px; }

.doc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 26px 0; }
.doc-card { min-height: 180px; display: flex; flex-direction: column; padding: 22px; color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: 6px; text-decoration: none; }
.doc-card:hover { border-color: var(--blue); box-shadow: 0 8px 24px rgba(7, 24, 43, 0.08); }
.doc-card .card-label { color: var(--cyan-dark); font-family: var(--utility); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; }
.doc-card h3 { margin: 9px 0 8px; font-size: 1.25rem; }
.doc-card p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }
.doc-card .card-link { margin-top: auto; padding-top: 18px; color: var(--blue); font-weight: 700; font-size: 0.84rem; }

.callout { margin: 24px 0; padding: 18px 20px; border-left: 5px solid var(--blue); background: #eef5ff; }
.callout strong { display: block; margin-bottom: 4px; }
.callout p { margin: 0; }
.callout.warning { border-left-color: var(--magenta); background: #fff2f6; }
.callout.info { border-left-color: var(--cyan-dark); background: #edfafa; }
.callout.success { border-left-color: var(--green); background: #eef9f4; }

.trust-model { margin: 28px 0; border-top: 1px solid var(--line); }
.trust-row { display: grid; grid-template-columns: 145px minmax(0, 1fr) minmax(0, 0.8fr); gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.trust-row strong { color: var(--blue); }
.trust-row span { color: var(--ink-soft); }
.trust-row small { color: #6a7d8f; font-size: 0.82rem; }

.architecture-flow { display: grid; grid-template-columns: repeat(4, 1fr); margin: 28px 0; border: 1px solid var(--line); }
.architecture-flow div { min-height: 125px; position: relative; padding: 18px; border-right: 1px solid var(--line); }
.architecture-flow div:last-child { border-right: 0; }
.architecture-flow div:not(:last-child)::after { content: "→"; position: absolute; z-index: 2; top: 45%; right: -11px; width: 22px; color: var(--blue); background: var(--white); text-align: center; font-weight: 800; }
.architecture-flow small, .architecture-flow strong { display: block; }
.architecture-flow small { margin-bottom: 8px; color: var(--cyan-dark); font-family: var(--utility); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; }
.architecture-flow span { display: block; margin-top: 6px; color: var(--ink-soft); font-size: 0.82rem; }

.table-wrap { max-width: 100%; margin: 24px 0; overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 13px 15px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: var(--ink); background: var(--paper); font-size: 0.78rem; }
tr:last-child td { border-bottom: 0; }

.steps { margin: 24px 0; padding: 0; list-style: none; counter-reset: step; border-top: 1px solid var(--line); }
.steps li { min-height: 70px; position: relative; padding: 18px 0 18px 58px; border-bottom: 1px solid var(--line); counter-increment: step; }
.steps li::before { content: counter(step); width: 34px; height: 34px; position: absolute; top: 16px; left: 0; display: grid; place-items: center; color: var(--white); background: var(--blue); border-radius: 50%; font-family: var(--utility); font-weight: 700; }

.code-block { position: relative; margin: 22px 0; overflow: hidden; color: #e9f3fb; background: #081b2f; border: 1px solid #27435d; border-radius: 6px; }
.code-label { display: flex; justify-content: space-between; padding: 8px 14px; color: #9fc5d9; background: #102a45; border-bottom: 1px solid #27435d; font-family: var(--utility); font-size: 0.7rem; }
.code-block pre { margin: 0; padding: 18px; overflow-x: auto; font: 0.82rem/1.65 var(--utility); }
.code-block code { padding: 0; color: inherit; background: transparent; border-radius: 0; font: inherit; }

.endpoint-list { margin: 24px 0; border-top: 1px solid var(--line); }
.endpoint { display: grid; grid-template-columns: 74px minmax(220px, 0.9fr) minmax(260px, 1.25fr); gap: 14px; align-items: baseline; padding: 15px 0; border-bottom: 1px solid var(--line); }
.endpoint code { color: var(--ink); background: transparent; }
.endpoint p { margin: 0; font-size: 0.87rem; }
.method { display: inline-flex; width: 64px; justify-content: center; padding: 3px 6px; color: var(--white); background: var(--blue); border-radius: 3px; font-family: var(--utility); font-size: 0.68rem; font-weight: 800; }
.method.get { background: var(--green); }
.method.patch { background: var(--amber); }
.method.delete { background: var(--magenta); }

.status-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 22px; }
.status { padding: 16px; border: 1px solid var(--line); border-left-width: 5px; border-radius: 5px; }
.status strong, .status span { display: block; }
.status span { margin-top: 5px; color: var(--ink-soft); font-size: 0.88rem; }
.status.pending { border-left-color: var(--amber); }
.status.success { border-left-color: var(--green); }
.status.denied { border-left-color: var(--magenta); }
.status.partial { border-left-color: var(--blue); }

.page-nav { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 58px; padding-top: 22px; border-top: 1px solid var(--line); }
.page-nav a { padding: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 5px; text-decoration: none; }
.page-nav a:last-child { text-align: right; }
.page-nav small, .page-nav strong { display: block; }
.page-nav small { color: #688096; font-size: 0.72rem; }
.page-nav strong { margin-top: 3px; }

.no-results { margin-top: 48px; padding: 28px; background: var(--paper); border: 1px solid var(--line); }
.no-results[hidden] { display: none; }

.docs-footer { padding: 24px 36px; color: #a9bece; background: var(--ink); border-top: 1px solid #223c55; font-size: 0.82rem; }
.docs-footer a { color: var(--white); }

@media (max-width: 980px) {
  .architecture-flow { grid-template-columns: repeat(2, 1fr); }
  .architecture-flow div:nth-child(2) { border-right: 0; }
  .architecture-flow div:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .architecture-flow div:nth-child(2)::after { display: none; }
  .endpoint { grid-template-columns: 74px minmax(0, 1fr); }
  .endpoint p { grid-column: 2; }
}

@media (max-width: 900px) {
  .docs-label, .header-links { display: none; }
  .menu-toggle { display: block; }
  .docs-shell { display: block; }
  .sidebar { width: min(86vw, 340px); height: calc(100vh - 68px); position: fixed; z-index: 25; inset: 68px auto 0 0; transform: translateX(-105%); transition: transform 180ms ease; }
  .sidebar[data-open="true"] { transform: none; box-shadow: 20px 0 50px rgba(7, 24, 43, 0.22); }
  .mobile-links { display: block; }
  .doc-content { width: min(100% - 40px, 1000px); padding-top: 44px; }
}

@media (max-width: 640px) {
  .docs-header { padding-inline: 14px; }
  .brand img { width: 126px; }
  .doc-content { width: min(100% - 28px, 1000px); }
  .doc-intro h1 { font-size: 2.45rem; }
  .doc-section h2 { font-size: 1.9rem; }
  .doc-grid, .status-list, .page-nav { grid-template-columns: 1fr; }
  .doc-card { min-height: 0; }
  .trust-row { grid-template-columns: 1fr; gap: 4px; }
  .architecture-flow { grid-template-columns: 1fr; }
  .architecture-flow div { min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .architecture-flow div:last-child { border-bottom: 0; }
  .architecture-flow div::after { display: none; }
  .endpoint { grid-template-columns: 68px minmax(0, 1fr); gap: 8px; }
  .endpoint code { font-size: 0.76rem; }
  .page-nav a:last-child { text-align: left; }
  .docs-footer { padding-inline: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sidebar { transition: none; }
}
