:root {
  --sidebar-width: 300px;
  --bg: #ffffff;
  --bg-sidebar: #f7f8f9;
  --bg-hover: #eef0f2;
  --border: #e6e9eb;
  --text: #23282c;
  --text-muted: #5c6266;
  --accent: #fe6a00;
  --accent-wash: #fff3ea;
  --link: #0063a4;
  --code-bg: #f4f5f6;
  --body: 'IBM Plex Sans', system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;
  color-scheme: light;
}

/* IBM Plex webfonts, bundled locally (copied into static/fonts/ by render.py).
   Fully offline: no CDN / Google Fonts request at runtime. */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Regular.woff2") format("woff2");
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Medium.woff2") format("woff2");
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Bold.woff2") format("woff2");
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/IBMPlexMono-Medium.woff2") format("woff2");
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/IBMPlexMono-SemiBold.woff2") format("woff2");
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.65;
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 1px;
}

.layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  overflow-y: auto;
  scrollbar-width: thin;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 8px 0;
  margin-bottom: 16px;
}

.sidebar-title {
  font-weight: 600;
  font-size: 15px;
  min-width: 0;
}

.sidebar-home {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
  margin-top: -2px;
}

.sidebar-home a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text-muted);
}

.sidebar-home a:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.sidebar-home .accent { stroke: var(--accent); }

.sidebar-title::after {
  content: "";
  display: block;
  width: 28px;
  height: 3px;
  margin-top: 8px;
  background: var(--accent);
  border-radius: 2px;
}

.search-box { position: relative; margin-bottom: 14px; }

#search-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

#search-input::placeholder { color: var(--text-muted); }

#search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(254, 106, 0, 0.15);
}

.search-results {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 60vh;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.search-results.open { display: block; }

.search-results a {
  display: block;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--bg-hover); color: var(--link); }
.search-results .no-results { padding: 10px; color: var(--text-muted); font-size: 13px; }

ul.toc-tree, .toc-tree ul {
  list-style: none;
  margin: 0;
  padding-left: 14px;
}

.toc-tree { padding-left: 0; }

.toc-tree li { margin: 1px 0; }

.toc-row {
  display: flex;
  align-items: center;
}

.toc-toggle {
  flex: 0 0 18px;
  width: 18px;
  height: 26px;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toc-toggle-empty { cursor: default; }

.toc-toggle::before {
  content: "▸";
  font-size: 10px;
  display: inline-block;
  transition: transform 0.12s ease;
}

.toc-toggle-empty::before { content: ""; }

.toc-node.expanded > .toc-row > .toc-toggle::before { transform: rotate(90deg); }

.toc-row > a {
  flex: 1 1 auto;
  min-width: 0;
}

.toc-tree a {
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  color: #3d4348;
  text-decoration: none;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-tree a:hover { background: var(--bg-hover); color: var(--text); }

.toc-tree a.active {
  background: var(--accent-wash);
  box-shadow: inset 2px 0 0 var(--accent);
  border-radius: 0 4px 4px 0;
  color: var(--text);
  font-weight: 600;
}

.toc-node.ancestor > .toc-row > a { font-weight: 600; }

.toc-children { display: none; }
.toc-node.expanded > .toc-children { display: block; }

.content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 32px 48px 96px;
  max-width: 880px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.breadcrumb { color: var(--text-muted); font-size: 12.5px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--link); text-decoration: underline; }
.crumb-current { color: var(--text); font-weight: 500; }

.topnav { display: flex; gap: 14px; }

.topnav-link {
  color: var(--link);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}

.topnav-link:hover { text-decoration: underline; }

.topic-header p {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topic-body img { max-width: 100%; height: auto; }

.topic-body table {
  border-collapse: collapse;
  margin: 12px 0;
  max-width: 100%;
}

.topic-body td { border: 1px solid var(--border); padding: 6px 10px; vertical-align: top; }
.topic-body thead td { background: var(--bg-sidebar); font-weight: 600; }

/* Equations: the raw LaTeX ships inside <span class="equation"> and is
   rendered client-side by katex-render.js. Until (or unless) that runs, the
   source is shown as monospace text as a graceful fallback. */
.topic-body .equation {
  display: block;
  margin: 16px 0;
  overflow-x: auto;
  overflow-y: hidden;
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: 13.5px;
}
.topic-body .equation .katex { font-size: 1.1em; }
.topic-body .equation .katex-display { margin: 0; }

.topic-body a { color: var(--link); }
.topic-body .broken-link { color: var(--text-muted); text-decoration: line-through; }
.topic-body .missing-image {
  display: inline-block;
  padding: 4px 8px;
  background: var(--code-bg);
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 4px;
  font-size: 12px;
}

.topic-body .tab { display: inline-block; width: 2em; }

/* ------------------------------------------------------------------ */
/* Content-pane typographic system (IBM Plex). The source hardcodes    */
/* legacy fonts in per-run inline styles; styles.restyle_typography    */
/* strips those so the family below governs, but leftover inline       */
/* font-weight / text-transform on the heading runs still need beating */
/* -- hence !important on the role rules and their descendant runs.    */
/* ------------------------------------------------------------------ */

/* Reading text: reinforce the body role on the content pane. */
.topic-body,
.topic-body p,
.topic-body li,
.topic-body td {
  font-family: var(--body);
  color: var(--text);
}

/* Section head (e.g. DESCRIPTION / PARAMETERS): heaviest, uppercased. */
.topic-body .style-Heading2,
.topic-body .style-Heading2 * {
  font-family: var(--body) !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em;
  color: var(--text);
}
.topic-body .style-Heading2 { margin: 36px 0 14px; }

/* Parameter name: one clear step below the section head -- semibold,   */
/* sentence case. Heading4/5/6 are nested parameter names in this       */
/* project (undefined as styleclasses), so they share the role; their   */
/* source margin-left carries the indentation hierarchy.                */
.topic-body .style-Heading3,
.topic-body .style-Heading3 *,
.topic-body .style-Heading4,
.topic-body .style-Heading4 *,
.topic-body .style-Heading5,
.topic-body .style-Heading5 *,
.topic-body .style-Heading6,
.topic-body .style-Heading6 * {
  font-family: var(--body) !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  color: var(--text);
}
.topic-body .style-Heading3 { margin: 20px 0 6px; }
.topic-body .style-Heading4,
.topic-body .style-Heading5,
.topic-body .style-Heading6 { margin: 10px 0 4px; }

/* Literal values & code: the ONLY place IBM Plex Mono is used. */
.topic-body .style-T_Code,
.topic-body .style-T_Code *,
.topic-body .style-Code-Example,
.topic-body .style-Code-Example * {
  font-family: var(--mono) !important;
  font-size: 0.9em;
  color: var(--text);
}

/* Inline parameter cross-reference (Part B): a slight underline, and a */
/* real link when auto-linked to the parameter's own #anchor.           */
.topic-body .pref {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: rgba(35, 40, 44, 0.4);
}
.topic-body a.pref { color: inherit; }
.topic-body a.pref:hover {
  color: var(--link);
  text-decoration-color: var(--link);
}

@media (prefers-reduced-motion: reduce) {
  .toc-toggle::before { transition: none; }
}

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-basis: auto; position: static; height: auto; max-height: 40vh; }
  .content { padding: 20px 20px 64px; max-width: none; }
}
