:root {
  color-scheme: dark;
  --bg: #111;
  --surface: #191919;
  --surface-2: #1e1e1e;
  --text: #efefef;
  --muted: #a6a6a6;
  --faint: #707070;
  --border: #323232;
  --accent: #be1450;
  --accent-2: #ef4b83;
  --topbar: 64px;
  --sidebar: 286px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 "Trebuchet MS", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: fixed;
  z-index: 30;
  left: 16px;
  top: -80px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 3px;
}
.skip:focus { top: 10px; }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: var(--topbar);
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 17, 17, .97);
}
.brand {
  display: flex;
  align-items: center;
  min-width: var(--sidebar);
  color: var(--text);
  text-decoration: none;
  border-right: 1px solid var(--border);
}
.brand strong {
  display: grid;
  align-self: stretch;
  place-items: center;
  padding: 0 22px;
  border-right: 1px solid var(--border);
  font: 700 19px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: -.04em;
}
.brand span {
  padding: 0 20px;
  color: var(--muted);
  white-space: nowrap;
  font: 14px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.source-links {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-left: auto;
  padding: 0 28px;
}
.source-links a {
  color: var(--text);
  text-decoration: none;
  font: 14px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.source-links a:hover { color: var(--accent-2); }
.menu-button {
  display: none;
  width: 54px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}
.menu-button svg, .search svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.layout { min-height: 100vh; padding-top: var(--topbar); }
.sidebar {
  position: fixed;
  z-index: 15;
  inset: var(--topbar) auto 0 0;
  width: var(--sidebar);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 18px 18px;
  padding: 0 13px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  background: var(--surface);
}
.search:focus-within { border-color: var(--accent); }
.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}
.search input::placeholder { color: var(--faint); }
.side-nav { padding: 4px 0 28px; }
.side-nav a {
  position: relative;
  display: block;
  padding: 11px 24px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.side-nav a:hover { color: var(--text); background: #171717; }
.side-nav a.active { color: var(--text); background: var(--surface); }
.side-nav a.active::before {
  content: "";
  position: absolute;
  inset: 9px auto 9px 0;
  width: 3px;
  background: var(--accent);
}
.nav-rule { display: block; margin: 14px 24px; border-top: 1px solid var(--border); }
.search-results { padding: 0 18px 16px; border-bottom: 1px solid var(--border); }
.search-results a { display: block; padding: 10px 4px; color: var(--text); text-decoration: none; border-bottom: 1px solid #262626; }
.search-results strong { display: block; font-size: 13px; }
.search-results span { display: block; color: var(--muted); font-size: 12px; line-height: 1.45; }
.search-empty { color: var(--muted); font-size: 13px; }

.main { margin-left: var(--sidebar); padding: 32px clamp(28px, 5vw, 76px) 80px; }
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  max-width: 1180px;
  margin: 0 auto 42px;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.facts span {
  flex: 1 1 220px;
  padding: 13px 18px;
  color: var(--muted);
  font: 13px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.facts span + span { border-left: 1px solid var(--border); }
.facts b { color: var(--text); font-weight: 500; }
.article, .loading { max-width: 1180px; margin: 0 auto; }
.article:focus { outline: 0; }
.loading { color: var(--muted); }
.loading[hidden] { display: none; }

.document h1 {
  margin: 0 0 28px;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.2;
  letter-spacing: -.035em;
}
.document h2 {
  margin: 58px 0 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: clamp(21px, 2.2vw, 28px);
  line-height: 1.3;
  letter-spacing: -.025em;
}
.document h3 { margin: 34px 0 12px; font-size: 19px; line-height: 1.35; }
.document h4 { margin: 26px 0 10px; font-size: 16px; }
.document p, .document ul, .document ol, .document blockquote { max-width: 820px; }
.document p { margin: 0 0 18px; }
.document ul, .document ol { margin: 0 0 22px; padding-left: 24px; }
.document li + li { margin-top: 7px; }
.document strong { color: white; }
.document a { color: #f06a99; text-underline-offset: 3px; }
.document a:hover { color: white; }
.document hr { margin: 42px 0; border: 0; border-top: 1px solid var(--border); }
.document blockquote {
  margin: 24px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  color: var(--muted);
}
.document code {
  padding: .1em .35em;
  border: 1px solid #2f2f2f;
  border-radius: 2px;
  background: var(--surface-2);
  color: #f1b0c7;
  font: .9em/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.document pre {
  position: relative;
  max-width: 100%;
  overflow: auto;
  margin: 22px 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #0b0b0b;
}
.document pre code { padding: 0; border: 0; background: transparent; color: #dedede; font-size: 13px; }
.copy-code {
  position: sticky;
  left: calc(100% - 96px);
  top: 0;
  float: right;
  margin: -12px -12px 8px 12px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}
.copy-code:hover { color: white; border-color: var(--accent); }
.document table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; margin: 22px 0 32px; font-size: 13px; }
.document th, .document td { padding: 10px 12px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.document th { background: var(--surface); }
.document img { max-width: 100%; height: auto; }
.source-note { padding: 13px 16px; border-left: 3px solid var(--accent); color: var(--muted); background: var(--surface); }

.index-list { margin: 28px 0 36px; border-top: 1px solid var(--border); }
.index-link {
  display: grid;
  grid-template-columns: 52px minmax(180px, 1fr) 2fr auto;
  gap: 18px;
  align-items: center;
  min-height: 70px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text) !important;
  text-decoration: none;
}
.index-link .number { color: var(--accent-2); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.index-link strong { font-size: 17px; }
.index-link .description { color: var(--muted); }
.index-link .arrow { color: var(--accent-2); }
.index-link:hover .arrow { transform: translateX(3px); }
.side-nav .nav-primary {
  margin: 6px 10px;
  padding: 11px 12px;
  border: 1px solid #4a2c38;
  border-radius: 3px;
  background: #21151a;
  color: white;
}
.side-nav .nav-primary.active,
.side-nav .nav-primary:hover { border-color: var(--accent); background: #2a171e; }
.start-link {
  display: flex;
  max-width: 820px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 26px 0 34px;
  padding: 18px 20px;
  border: 1px solid #4a2c38;
  border-left: 4px solid var(--accent);
  background: linear-gradient(90deg, #21151a, var(--surface));
  color: white !important;
  text-decoration: none;
}
.start-link span { color: var(--muted); font-size: 13px; }
.start-link:hover { border-color: var(--accent); }

.download-list { border-top: 1px solid var(--border); }
.download-row {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 2fr auto;
  gap: 18px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.download-row span { color: var(--muted); }
.download-row a { white-space: nowrap; }

.download-button {
  align-self: start;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: white !important;
  background: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  font: 13px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.download-button:hover { background: #d0195a; }
.code-workspace { max-width: none; }
.code-workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: flex-start;
  margin-bottom: 28px;
}
.code-workspace-head h1 { margin-bottom: 12px; }
.code-workspace-head p { margin-bottom: 0; }
.code-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 680px;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  background: #0b0b0b;
}
.code-files {
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.code-filter { display: block; padding: 14px; border-bottom: 1px solid var(--border); }
.code-filter span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font: 11px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.code-filter input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  outline: 0;
  background: #111;
  color: var(--text);
  font-size: 12px;
}
.code-filter input:focus { border-color: var(--accent); }
.code-file-list { max-height: 620px; overflow: auto; padding: 7px 0; }
.code-file-list button {
  display: block;
  width: 100%;
  padding: 9px 14px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.code-file-list button:hover { color: white; background: #202020; }
.code-file-list button.active { color: white; border-left-color: var(--accent); background: #242424; }
.code-file-list .search-empty { padding: 8px 14px; }
.code-viewer { min-width: 0; }
.code-viewer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  min-height: 54px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #141414;
}
.code-viewer-bar strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 13px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.code-viewer-bar button {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  font-size: 11px;
}
.code-viewer-bar button:hover { color: white; border-color: var(--accent); }
.code-viewer pre {
  height: 624px;
  margin: 0;
  padding: 20px;
  border: 0;
  border-radius: 0;
}
.code-viewer pre code { white-space: pre; }

.pdf-shell { min-height: 72vh; border: 1px solid var(--border); background: var(--surface); }
.pdf-shell object { display: block; width: 100%; height: 76vh; border: 0; }
.pdf-fallback { padding: 24px; }
.pdf-mobile { display: none; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .85fr); gap: 38px; }
.overview-copy { min-width: 0; }
.overview-copy h2 { margin-top: 34px; }
.overview-pdf { align-self: start; min-width: 0; border: 1px solid var(--border); background: var(--surface); }
.overview-pdf-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; min-height: 54px; padding: 12px 15px; border-bottom: 1px solid var(--border); }
.overview-pdf-head strong { font-size: 14px; }
.overview-pdf-head a { color: var(--accent-2); font-size: 13px; text-decoration: none; }
.overview-pdf object { display: block; width: 100%; height: 650px; border: 0; background: #242424; }

.checklist { margin: 24px 0; border-top: 1px solid var(--border); }
.check-item { display: flex; gap: 12px; align-items: flex-start; padding: 16px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.check-item input { position: absolute; opacity: 0; pointer-events: none; }
.check-box { flex: 0 0 21px; width: 21px; height: 21px; border: 1px solid #777; margin-top: 2px; }
.check-item input:checked + .check-box { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px var(--bg); }
.check-item input:focus-visible + .check-box { outline: 2px solid var(--accent-2); outline-offset: 3px; }
.check-item input:checked ~ span:last-child { color: var(--faint); text-decoration: line-through; }

.overlay { position: fixed; z-index: 14; inset: var(--topbar) 0 0; background: rgba(0,0,0,.62); }
.noscript { margin: 100px auto; max-width: 720px; padding: 20px; }

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }

@media (max-width: 860px) {
  :root { --topbar: 58px; }
  .menu-button { display: grid; place-items: center; flex: 0 0 54px; }
  .brand { min-width: 0; border-right: 0; }
  .brand strong { padding: 0 14px; border-right: 0; font-size: 17px; }
  .brand span { display: none; }
  .source-links { gap: 16px; padding: 0 14px; }
  .source-links a { font-size: 12px; }
  .sidebar { transform: translateX(-100%); width: min(86vw, 320px); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 24px 20px 64px; }
  .facts { margin-bottom: 30px; }
  .facts span { flex-basis: 50%; }
  .facts span:nth-child(3) { border-left: 0; border-top: 1px solid var(--border); }
  .index-link { grid-template-columns: 38px 1fr auto; gap: 10px; }
  .index-link .description { grid-column: 2 / -1; }
  .download-row { grid-template-columns: 1fr auto; }
  .download-row span { grid-column: 1 / -1; }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .overview-pdf { display: none; }
  .code-layout { grid-template-columns: 220px minmax(0, 1fr); }
  body.menu-open { overflow: hidden; }
}

@media (max-width: 520px) {
  .start-link { display: block; }
  .start-link span { display: block; margin-top: 6px; }
  .source-links { gap: 12px; padding-right: 10px; }
  .facts span { flex-basis: 100%; }
  .facts span + span { border-left: 0; border-top: 1px solid var(--border); }
  .document h2 { margin-top: 44px; }
  .document pre { margin-left: -20px; margin-right: -20px; border-left: 0; border-right: 0; border-radius: 0; }
  .download-row { grid-template-columns: 1fr; gap: 5px; }
  .download-row span { grid-column: auto; }
  .pdf-shell { margin-left: -20px; margin-right: -20px; border-left: 0; border-right: 0; }
  .pdf-shell { min-height: 0; padding: 20px; }
  .pdf-shell object { display: none; }
  .pdf-mobile { display: block; margin: 0; }
  .code-workspace-head { display: block; }
  .code-workspace-head .download-button { display: inline-block; margin-top: 4px; }
  .code-layout { display: block; margin-left: -20px; margin-right: -20px; border-left: 0; border-right: 0; }
  .code-files { border-right: 0; border-bottom: 1px solid var(--border); }
  .code-file-list { display: flex; max-height: none; overflow-x: auto; padding: 0; }
  .code-file-list button { flex: 0 0 auto; width: auto; max-width: 230px; border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .code-file-list button.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .code-viewer pre { height: 62vh; margin: 0; }
}

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