:root {
  color-scheme: light;
  --paper: #f6f6ef;
  --surface: #fffdf7;
  --surface-strong: #ffffff;
  --ink: #222222;
  --muted: #666666;
  --faint: #858079;
  --border: #d7d3c8;
  --border-soft: #e8e3d7;
  --accent: #ff6600;
  --accent-dark: #c94f00;
  --code: #172027;
  --code-ink: #f4f1e8;
  --success: #1f6f43;
  --warning: #8a4b08;
  --danger: #9d2922;
  --header-height: 57px;
  --nav-width: 248px;
  --toc-width: 184px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Verdana, Geneva, sans-serif;
  font-size: 15px;
  line-height: 1.65;
}

a { color: #165d88; text-underline-offset: 3px; }
a,
button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 102, 0, 0.18);
}
a:hover { color: #0a4264; }
a:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(255, 102, 0, 0.35);
  outline-offset: 2px;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(246, 246, 239, 0.97);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}
.brand img { border-radius: 5px; }
.brand .docs-word {
  padding-left: 10px;
  border-left: 1px solid var(--border);
  color: var(--muted);
  font-weight: 400;
}

.header-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
}

.docs-layout {
  max-width: 1390px;
  min-height: calc(100vh - var(--header-height));
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 860px) var(--toc-width);
  align-items: start;
}

.site-nav {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 24px 20px 36px;
  border-right: 1px solid var(--border);
}
.nav-group { margin-bottom: 24px; }
.nav-label,
.toc-label {
  margin-bottom: 7px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
}
.site-nav a,
.toc a {
  display: block;
  color: #504d48;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
}
.site-nav a {
  margin: 2px -8px;
  padding: 7px 9px;
  border-left: 2px solid transparent;
}
.site-nav a:hover { background: #eeeade; color: var(--ink); }
.site-nav a[aria-current="page"] {
  border-left-color: var(--accent);
  background: #f0ead8;
  color: var(--ink);
  font-weight: 700;
}

.content {
  min-width: 0;
  padding: 46px 56px 64px;
}
.content > :first-child { margin-top: 0; }

h1, h2, h3 {
  color: #171717;
  line-height: 1.28;
  letter-spacing: -0.015em;
  scroll-margin-top: 76px;
  text-wrap: balance;
}
h1 { margin: 0 0 14px; font-size: clamp(30px, 4vw, 40px); }
h2 {
  margin: 48px 0 14px;
  padding-top: 5px;
  border-top: 1px solid var(--border-soft);
  font-size: 24px;
}
h3 { margin: 28px 0 10px; font-size: 17px; }
p { max-width: 76ch; margin: 0 0 17px; }
.lead { max-width: 70ch; color: #4d4943; font-size: 17px; line-height: 1.65; }

ul, ol { max-width: 76ch; padding-left: 24px; }
li { margin: 6px 0; }

.notice {
  margin: 24px 0;
  padding: 13px 15px;
  border: 1px solid #e3c593;
  border-left: 4px solid var(--accent);
  background: #fff9ed;
  color: #4d3a20;
}
.notice strong { color: #2e2519; }
.notice.danger { border-color: #dab5b0; border-left-color: var(--danger); background: #fff7f5; }
.notice.success { border-color: #b8d5c2; border-left-color: var(--success); background: #f5fbf7; }

.definition-list {
  margin: 22px 0;
  border-top: 1px solid var(--border);
}
.definition-list > div {
  display: grid;
  grid-template-columns: minmax(235px, 0.42fr) minmax(0, 1fr);
  gap: 22px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.definition-list dt { font-weight: 700; }
.definition-list dd { margin: 0; color: #4c4944; }

.flow {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 22px 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  background: var(--surface);
}
.flow li {
  margin: 0;
  padding: 9px 12px;
  border-right: 1px solid var(--border);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}
.flow li:last-child { border-right: 0; }

pre {
  position: relative;
  max-width: 100%;
  margin: 18px 0 24px;
  overflow: auto;
  border: 1px solid #0d151a;
  border-radius: 6px;
  background: var(--code);
  color: var(--code-ink);
  padding: 17px 18px;
  line-height: 1.55;
  tab-size: 2;
}
code, pre {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}
:not(pre) > code {
  padding: 2px 5px;
  border: 1px solid #ddd6c8;
  border-radius: 4px;
  background: #f0eadf;
  color: #493323;
  overflow-wrap: anywhere;
}
.code-wrap { position: relative; }
.copy-code {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  border: 1px solid #49545d;
  border-radius: 5px;
  background: #242e35;
  color: #f4f1e8;
  padding: 5px 8px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.copy-code:hover { background: #34414a; }

table {
  width: 100%;
  margin: 20px 0 28px;
  border-collapse: collapse;
  font-size: 13px;
}
th, td { padding: 10px 12px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #eeeade; font-weight: 700; }
td { background: var(--surface); }

.toc {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  padding: 24px 16px;
  border-left: 1px solid var(--border-soft);
}
.toc a { padding: 5px 0; color: var(--muted); }
.toc a:hover { color: var(--ink); }

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 64px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 12px;
}

@media (max-width: 1060px) {
  .docs-layout { grid-template-columns: var(--nav-width) minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 760px) {
  .site-header { padding: 0 14px; }
  .header-status { display: none; }
  .nav-toggle { display: block; margin-left: auto; }
  .docs-layout { display: block; }
  .site-nav {
    display: none;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    z-index: 15;
    height: auto;
    border-right: 0;
    background: var(--paper);
  }
  .site-nav[data-open="true"] { display: block; }
  .content { padding: 34px 20px 52px; }
  .definition-list > div { grid-template-columns: 1fr; gap: 4px; }
  .flow { display: block; }
  .flow li { border-right: 0; border-bottom: 1px solid var(--border); }
  .flow li:last-child { border-bottom: 0; }
  .page-footer { display: block; }
  .page-footer span { display: block; margin-top: 5px; }
}

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