/* ============================================================================
 * Open Agentic Workbench — Single Sticky 46px Masthead, TOC-First Drawer,
 * Pinned Bottom Appearance Swatch Dock, Non-Sticky Breadcrumb & Sidecar (v9.9)
 * File size budget: <= 290 lines
 * ============================================================================ */

html, body {
  margin: 0; padding: 0; width: 100%; height: 100vh; height: 100dvh; max-height: 100dvh;
  display: flex; flex-direction: column; background: var(--bg-canvas); color: var(--ink-primary);
  font-family: var(--font-sans); -webkit-font-smoothing: antialiased; overflow: hidden;
}

/* 1. Single Sticky 46px Top Masthead (Python Docs / Sphinx Pattern) */
.pub-header-stack {
  flex-shrink: 0; display: flex; flex-direction: column; z-index: 95;
  background: var(--bg-elevated); border-bottom: 1px solid var(--border-grid);
}
.pub-masthead {
  height: 46px; min-height: 46px; max-height: 46px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px;
}
.pub-masthead-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; }
.va-hamburger-btn {
  width: 32px; height: 32px; padding: 0; background: transparent; border: none; border-radius: var(--radius-ui);
  color: var(--ink-primary); font-size: 1.02rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.va-hamburger-btn:hover { background: var(--bg-recessed); }
.pub-brand {
  font-family: var(--font-sans); font-size: 0.90rem; font-weight: 800; letter-spacing: 0.02em;
  color: var(--ink-primary); white-space: nowrap; flex-shrink: 0;
  display: inline-flex; align-items: center; padding: 4px 6px; border-radius: var(--radius-ui); background: transparent; border: none;
}
.masthead-select {
  height: 32px; min-height: 32px; background: var(--bg-canvas); border: 1px solid var(--border-grid); border-radius: var(--radius-ui);
  color: var(--ink-primary); font-family: var(--font-sans); font-size: 0.80rem; font-weight: 600; padding: 0 8px; cursor: pointer;
}
.masthead-select:hover, .masthead-btn:hover, .top-quick-search-wrap:focus-within { border-color: var(--ink-muted); }
.pub-masthead-right { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; justify-content: flex-end; min-width: 0; }
.top-quick-search-wrap, .masthead-search-form {
  display: flex; align-items: center; flex: 1 1 0; max-width: 300px; min-width: 0; height: 32px; min-height: 32px;
  border: 1px solid var(--border-grid); border-radius: var(--radius-ui); background: var(--bg-canvas); overflow: hidden;
}
.top-quick-search-input {
  flex: 1; min-width: 0; height: 100%; border: none; border-radius: 0; background: transparent; color: var(--ink-primary);
  font-family: var(--font-sans); font-size: 0.80rem; padding: 0 8px; outline: none;
}
.top-quick-search-go { height: 100%; border: none; border-left: 1px solid var(--border-grid); border-radius: 0; background: var(--bg-elevated); color: var(--ink-secondary); font-family: var(--font-sans); font-size: 0.75rem; font-weight: 600; padding: 0 9px; cursor: pointer; flex-shrink: 0; }
.top-quick-search-go:hover { background: var(--bg-recessed); color: var(--ink-primary); }
.top-search-go-ico { display: none; }
.masthead-btn {
  height: 32px; min-height: 32px; background: var(--bg-canvas); border: 1px solid var(--border-grid); border-radius: var(--radius-ui);
  color: var(--ink-primary); font-family: var(--font-sans); font-size: 0.76rem; font-weight: 600; padding: 0 10px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex-shrink: 0;
}
.masthead-btn:hover { background: var(--bg-recessed); }
.masthead-btn.active { background: var(--sig-border); border-color: var(--sig-border); color: #ffffff; }

/* 2. 3-Pane Workspace Layout & TOC-First Navigation Drawer */
.pub-workspace {
  --toc-sidebar-w: 292px; --code-drawer-w: 36px; position: relative; flex: 1; min-height: 0;
  height: calc(100dvh - 46px); display: grid; grid-template-columns: var(--toc-sidebar-w) minmax(0, 1fr) var(--code-drawer-w);
  grid-template-rows: minmax(0, 1fr); overflow: hidden;
}
.toc-sidebar, .whitepaper-main, .code-drawer { height: 100%; max-height: calc(100dvh - 46px); min-height: 0; min-width: 0; }
.pub-workspace[data-code-drawer="expanded"] { --code-drawer-w: 440px; }
.pub-workspace[data-toc-collapsed="true"], html.is-rail-collapsed .pub-workspace { --toc-sidebar-w: 0px; }
.pub-workspace[data-toc-collapsed="true"] .toc-sidebar, html.is-rail-collapsed .toc-sidebar { border-right: none; }

.mobile-drawer-backdrop { position: fixed; top: 46px; left: 0; right: 0; bottom: 0; background: rgba(15, 20, 25, 0.45); z-index: 85; }
.mobile-drawer-backdrop.hidden { display: none; }

.toc-sidebar { background: var(--bg-elevated); border-right: 1px solid var(--border-grid); display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.toc-search-box { padding: 10px 12px; border-bottom: 1px solid var(--border-grid); background: var(--bg-canvas); flex-shrink: 0; }
.toc-section-heading { font-family: var(--font-sans); font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-secondary); margin-bottom: 6px; }
.toc-search-input-wrap { position: relative; display: flex; align-items: center; }
.toc-search-icon { position: absolute; left: 9px; font-size: 0.74rem; color: var(--ink-muted); pointer-events: none; }
.toc-search-input {
  width: 100%; height: 30px; padding: 4px 8px 4px 26px; font-family: var(--font-sans); font-size: 0.78rem;
  background: var(--bg-elevated); color: var(--ink-primary); border: 1px solid var(--border-grid); border-radius: var(--radius-ui);
}
.toc-filter-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin-top: 7px; padding: 2px;
  background: var(--bg-recessed); border: 1px solid var(--border-grid); border-radius: var(--radius-ui);
}
.toc-tab-btn {
  background: transparent; border: none; border-radius: calc(var(--radius-ui) - 2px); color: var(--ink-secondary);
  font-family: var(--font-sans); font-size: 0.71rem; font-weight: 600; padding: 4px 4px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.toc-tab-btn:hover { color: var(--ink-primary); }
.toc-tab-btn.active { background: var(--bg-canvas); color: var(--ink-primary); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08); }

.toc-tree-mount { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.toc-chapter-btn {
  width: 100%; text-align: left; background: transparent; border: none; border-radius: var(--radius-ui);
  padding: 6px 8px; font-family: var(--font-sans); font-size: 0.81rem; font-weight: 600; color: var(--ink-secondary); cursor: pointer; display: flex; align-items: center; gap: 7px; position: relative;
}
.toc-chapter-btn:hover { background: var(--bg-canvas); color: var(--ink-primary); }
.toc-chapter-btn.active { background: var(--sig-bg); color: var(--ink-primary); font-weight: 700; padding-left: 14px; }
.toc-chapter-children { display: flex; flex-direction: column; gap: 2px; padding: 3px 0 6px 6px; margin-left: 8px; border-left: 1px solid var(--border-grid); }
.toc-h2-link {
  flex-shrink: 0; display: block; margin-top: 2px; padding: 5px 8px 5px 12px; color: var(--ink-secondary); font-family: var(--font-sans); font-size: 0.77rem;
  font-weight: 500; line-height: 1.3; text-decoration: none; border-radius: var(--radius-ui); position: relative; background: transparent;
}
.toc-h2-link:hover { background: var(--bg-canvas); color: var(--ink-primary); }
.toc-h2-link.active { background: var(--sig-bg); color: var(--ink-primary); font-weight: 600; padding-left: 14px; }
.toc-h3-link {
  flex-shrink: 0; display: block; margin-left: 8px; padding: 3px 8px; border-radius: var(--radius-ui);
  color: var(--ink-muted); font-family: var(--font-sans); font-size: 0.74rem; line-height: 1.35; text-decoration: none; position: relative;
}
.toc-h3-link:hover { color: var(--ink-primary); background: var(--bg-canvas); }
.toc-h3-link.active { background: var(--sig-bg); color: var(--ink-primary); font-weight: 600; padding-left: 14px; }
.toc-fig-link {
  flex-shrink: 0; display: flex; align-items: baseline; gap: 6px; margin-left: 8px; padding: 3px 8px; border-radius: var(--radius-ui);
  font-family: var(--font-sans); font-size: 0.74rem; line-height: 1.35; color: var(--ink-secondary); text-decoration: none; position: relative;
}
.toc-fig-link:hover { background: var(--bg-canvas); color: var(--ink-primary); }
.toc-fig-link.active { background: var(--sig-bg); color: var(--ink-primary); font-weight: 600; padding-left: 14px; }
.toc-fig-badge {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600; color: var(--accent-link); background: var(--sig-bg);
  padding: 1px 5px; border-radius: 4px; flex-shrink: 0;
}
.toc-chapter-btn.active::before, .toc-h2-link.active::before, .toc-h3-link.active::before, .toc-fig-link.active::before {
  content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 3px; border-radius: 99px; background: var(--sig-border);
}

/* 3. Appearance Swatches & Density Controls (Reused in Popovers) */
.theme-swatch-group { display: flex; align-items: center; gap: 8px; }
.theme-swatch-btn { background: transparent; border: none; padding: 2px; cursor: pointer; display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.swatch-dot { width: 24px; height: 24px; border-radius: 999px !important; display: block; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.swatch-white { background: #ffffff; border: 1.5px solid #cbd5e1; } .swatch-paper { background: #fbf9f5; border: 1.5px solid #d6d0c4; }
.swatch-sepia { background: #f4ecd8; border: 1.5px solid #c8b99a; } .swatch-dark { background: #0f172a; border: 1.5px solid #475569; }
.theme-swatch-btn.active .swatch-dot { box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 4px var(--sig-border); }
.swatch-label { font-family: var(--font-sans); font-size: 0.64rem; font-weight: 500; color: var(--ink-muted); line-height: 1; }
.theme-swatch-btn.active .swatch-label { color: var(--ink-primary); font-weight: 700; }

.corner-toggle-pill { display: inline-flex; background: var(--bg-recessed); padding: 2px; gap: 2px; border: 1px solid var(--border-grid); border-radius: var(--radius-ui); }
.corner-opt-btn, .density-opt-btn {
  background: transparent; border: none; border-radius: calc(var(--radius-ui) - 2px); color: var(--ink-secondary);
  font-family: var(--font-sans); font-size: 0.71rem; font-weight: 600; padding: 4px 7px; cursor: pointer;
}
.corner-opt-btn.active, .density-opt-btn.active { background: var(--bg-canvas); color: var(--ink-primary); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08); }
.density-segmented-pill {
  width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  background: var(--bg-recessed); padding: 2px; border: 1px solid var(--border-grid); border-radius: var(--radius-ui);
}

/* 4. Center Whitepaper Reading Column, Non-Sticky Breadcrumb & Booktabs Typography */
.whitepaper-main { height: 100%; overflow-y: auto; overflow-x: hidden; background: var(--bg-canvas); scroll-behavior: smooth; }
.monograph-article { max-width: 1080px; margin: 0 auto; padding: 18px 44px 96px; }
.monograph-header { border-bottom: 1px solid var(--border-grid); padding-bottom: 14px; margin-bottom: 22px; }
.doc-breadcrumb-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px;
  padding: 0 0 10px; margin-bottom: 12px; border-bottom: 1px solid var(--border-grid); font-family: var(--font-sans); font-size: 0.78rem; color: var(--ink-secondary);
}
.doc-breadcrumb-trail { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; }
.bc-root, .bc-root-btn {
  font-family: var(--font-sans); font-size: 0.78rem; font-weight: 800; color: var(--accent-link);
  background: transparent; border: none; padding: 2px 4px; cursor: pointer; border-radius: var(--radius-ui);
  display: inline-flex; align-items: center; text-decoration: none;
}
.bc-root:hover, .bc-root-btn:hover { background: var(--bg-recessed); }
.bc-sep, .bc-divider { color: var(--ink-muted); font-size: 0.75rem; }
.bc-subject { color: var(--ink-secondary); font-weight: 600; white-space: nowrap; }
.bc-chapter-select {
  height: 28px; background: var(--bg-elevated); border: 1px solid var(--border-grid); border-radius: var(--radius-ui);
  color: var(--ink-primary); font-family: var(--font-sans); font-size: 0.78rem; font-weight: 600; padding: 0 8px; cursor: pointer; max-width: 100%;
}
.bc-edition-select {
  height: 28px; background: var(--bg-canvas); border: 1px solid var(--border-grid); border-radius: var(--radius-ui);
  color: var(--ink-primary); font-family: var(--font-sans); font-size: 0.74rem; font-weight: 500; padding: 0 6px; cursor: pointer;
}
.bc-diff-btn {
  height: 28px; padding: 0 8px; background: var(--bg-canvas); border: 1px solid var(--border-grid); border-radius: var(--radius-ui);
  color: var(--ink-primary); font-family: var(--font-sans); font-size: 0.72rem; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex-shrink: 0;
}
.bc-diff-btn:hover { background: var(--bg-recessed); }
.bc-diff-btn.active { background: var(--sig-border); border-color: var(--sig-border); color: #ffffff; }
.bc-diff-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.doc-breadcrumb-links { display: flex; align-items: center; gap: 6px; font-size: 0.76rem; margin-left: auto; flex-shrink: 0; }
.bc-nav-link { background: transparent; border: none; padding: 2px 0; color: var(--accent-link); font-family: var(--font-sans); font-size: 0.76rem; cursor: pointer; }
.bc-nav-link:hover { text-decoration: underline; } .bc-nav-link:disabled { color: var(--ink-muted); cursor: default; text-decoration: none; opacity: 0.5; }
.monograph-content { font-family: var(--font-serif); font-size: var(--prose-size); line-height: var(--prose-lh); color: var(--ink-primary); }
.monograph-content h1, .monograph-content h2, .monograph-content h3, .monograph-content h4 { font-family: var(--font-serif); color: var(--ink-primary); margin: 1.6rem 0 0.75rem; line-height: 1.25; }
.monograph-content h1 { font-size: 1.95rem; border-bottom: 1px solid var(--border-grid); padding-bottom: 0.5rem; }
.monograph-content h2 { font-size: 1.45rem; border-bottom: 1px solid var(--border-grid); padding-bottom: 0.3rem; }
.monograph-content h3 { font-family: var(--font-serif); font-size: 1.18rem; font-weight: 600; }
.monograph-content p { margin: 0 0 1rem; }
.monograph-content code { font-family: var(--font-mono); font-size: 0.88em; background: var(--bg-elevated); padding: 1px 5px; border: 1px solid var(--border-hairline); border-radius: 4px; }
.monograph-content pre code { border: none; padding: 0; background: transparent; }
.monograph-content pre {
  font-family: var(--font-mono); font-size: 0.82rem; background: var(--bg-elevated); border: 1px solid var(--border-grid);
  border-left: 3px solid var(--sig-border); border-radius: var(--radius-card); padding: 12px 16px; overflow-x: auto; margin: 1rem 0;
}
.table-scroll-wrapper {
  overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%;
  border: 1px solid var(--border-grid); border-radius: var(--radius-card); margin: 1.25rem 0; background: var(--bg-canvas);
}
.table-scroll-wrapper > table { margin: 0 !important; min-width: 480px; }
.monograph-content table, table.booktabs {
  width: 100%; border-collapse: collapse; margin: 1.25rem 0;
  border-top: 2px solid var(--border-strong); border-bottom: 2px solid var(--border-strong); font-family: var(--font-sans); font-size: 0.86rem;
}
.monograph-content th, table.booktabs th {
  text-align: left; padding: var(--table-cell-pad); border-bottom: 1px solid var(--border-strong);
  background: var(--bg-elevated); font-family: var(--font-mono); font-size: 0.74rem; text-transform: uppercase;
}
.monograph-content td, table.booktabs td { padding: var(--table-cell-pad); border-bottom: 1px solid var(--border-hairline); }
.monograph-content ul, .monograph-content ol { padding-left: 1.35rem !important; margin: 0 0 1rem 0 !important; list-style-position: outside; }
.monograph-content li { margin-bottom: 0.55rem; padding-left: 0.2rem; }
.monograph-content .katex { font-size: 0.96em; white-space: nowrap; }
.monograph-content .katex-display { border-radius: var(--radius-card); }
.monograph-content .katex-display > .katex { white-space: normal; }
.monograph-content [data-block-id] { position: relative; }
.monograph-content [data-block-id]:hover > .block-gutter-btn, .block-gutter-btn:focus-visible { opacity: 1; }
.block-gutter-btn {
  position: absolute; left: -28px; top: 4px; width: 22px; height: 22px;
  background: var(--bg-elevated); border: 1px solid var(--border-grid); border-radius: var(--radius-ui); color: var(--ink-muted);
  font-size: 0.68rem; display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; transition: opacity 0.12s ease;
}
.block-gutter-btn:hover { background: var(--sig-border); color: #ffffff; border-color: var(--sig-border); }

/* 5. Right-Hand Collapsible Python Companion Code Sidecar & IDE Syntax Highlighting */
.code-drawer { background: var(--bg-code-drawer); color: var(--ink-code-drawer); border-left: 1px solid var(--border-grid); height: 100%; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.pub-workspace[data-code-drawer="collapsed"] .code-drawer-content, .pub-workspace[data-code-drawer="expanded"] .code-drawer-rail { display: none; }
.code-drawer-rail { width: 36px; height: 100%; display: flex; flex-direction: column; align-items: center; padding-top: 14px; cursor: pointer; background: var(--bg-code-drawer); }
.code-rail-btn { background: transparent; border: none; color: #38bdf8; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 6px 0; }
.code-rail-vertical-label { writing-mode: vertical-rl; text-orientation: mixed; font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; color: #94a3b8; }
.code-drawer-content { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }
.code-drawer-header { padding: 10px 12px; background: #090d16; border-bottom: 1px solid var(--border-code-drawer); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-shrink: 0; }
.code-drawer-title-group { display: flex; flex-direction: column; min-width: 0; }
.code-drawer-kicker { font-family: var(--font-mono); font-size: 0.65rem; font-weight: 700; color: #38bdf8; letter-spacing: 0.06em; }
.code-drawer-subtitle { font-family: var(--font-sans); font-size: 0.80rem; font-weight: 600; color: #f8fafc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code-drawer-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.code-action-btn { background: #1e293b; border: 1px solid #334155; border-radius: var(--radius-ui); color: #cbd5e1; font-family: var(--font-mono); font-size: 0.67rem; font-weight: 600; padding: 4px 7px; cursor: pointer; }
.code-action-btn.active { background: #0284c7; border-color: #38bdf8; color: #ffffff; }
.code-nuggets-mount { flex: 1 1 0%; min-height: 0; overflow-y: auto !important; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 12px 12px 48px; display: flex; flex-direction: column; gap: 10px; }
.code-nugget { flex-shrink: 0; border: 1px solid #1e293b; border-radius: var(--radius-card); background: #0b0f17; overflow: hidden; }
.code-nugget.active-nugget { border-color: #38bdf8; box-shadow: 0 0 0 1px #38bdf8; }
.code-nugget-summary { padding: 8px 12px; background: #161f30; color: #f8fafc; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--font-sans); font-size: 0.78rem; font-weight: 600; }
.code-nugget-summary::-webkit-details-marker { display: none; }
.nugget-fig-tag { font-family: var(--font-mono); font-size: 0.70rem; font-weight: 700; color: #38bdf8; background: rgba(56, 189, 248, 0.12); padding: 2px 6px; border-radius: 4px; flex-shrink: 0; }
.code-nugget-title { color: #e2e8f0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.76rem; font-weight: 600; }
.code-copy-btn { background: #1e293b; border: 1px solid #475569; border-radius: var(--radius-ui); color: #e2e8f0; font-family: var(--font-mono); font-size: 0.66rem; padding: 3px 8px; cursor: pointer; flex-shrink: 0; transition: all 0.12s ease; }
.code-copy-btn:hover { background: #334155; border-color: #64748b; color: #ffffff; }
.nugget-chevron { font-size: 0.65rem; color: #8b949e; flex-shrink: 0; transition: transform 0.15s ease; }
details[open] .nugget-chevron { transform: rotate(180deg); }
.code-nugget-pre { max-height: 320px; max-width: 100%; overflow: auto !important; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; white-space: pre; tab-size: 4; margin: 0; padding: 10px 12px; font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.55; color: #e2e8f0; background: #070a10; border-top: 1px solid #1e293b; }
.py-ln { user-select: none; display: inline-block; width: 2.5ch; margin-right: 12px; text-align: right; color: #4b5563; }
.py-com { color: #6e7681; font-style: italic; } .py-str { color: #a5d6ff; } .py-kw { color: #ff7b72; font-weight: 600; }
.py-bi { color: #79c0ff; } .py-fn { color: #d2a8ff; } .py-num { color: #f2cc60; }

/* 6. Responsive Off-Canvas Drawers Anchored Below 46px Top Bar (< 1100px) & Single-Row Mobile Breadcrumb */
@media (max-width: 1100px) {
  .pub-workspace { grid-template-columns: minmax(0, 1fr) !important; }
  #codeDrawerRail, .code-drawer-rail { display: none !important; }
  #tocSidebar {
    position: fixed; top: 46px; bottom: 0; left: 0; height: calc(100dvh - 46px); z-index: 90; width: min(320px, 86vw);
    border-right: 1px solid var(--border-grid); box-shadow: 6px 0 20px rgba(0, 0, 0, 0.14);
    transform: translateX(-105%); transition: transform 0.2s ease;
  }
  #tocSidebar.mobile-open, #codeDrawer.mobile-open { transform: translateX(0); }
  #codeDrawer {
    position: fixed; top: 46px; bottom: 0; right: 0; height: calc(100dvh - 46px); z-index: 90; width: min(440px, 92vw);
    transform: translateX(105%); transition: transform 0.2s ease;
  }
  #codeDrawer.mobile-open .code-drawer-content { display: flex !important; }
  .monograph-article { padding: 16px 24px 88px; }
}
@media (max-width: 960px) {
  .btn-label-desktop:not(.oaw-user-label) { display: none !important; }
  .masthead-icon-btn { width: 32px; height: 32px; min-height: 32px; padding: 0; font-size: 0.88rem; }
}
@media (max-width: 768px) {
  .pub-masthead { padding: 0 8px; gap: 6px; }
  #track-select { height: 32px; max-width: 112px; font-size: 0.78rem; font-weight: 600; padding: 0 6px; }
  .monograph-article { padding: 14px 20px 80px !important; box-sizing: border-box; width: 100%; max-width: 100vw; overflow-x: hidden; }
  .monograph-content { font-size: 0.975rem; line-height: 1.62; text-wrap: pretty; }
  .monograph-content h1 { font-size: 1.38rem; line-height: 1.25; margin-bottom: 0.75rem; }
  .monograph-content h2 { font-size: 1.15rem; line-height: 1.3; margin-top: 1.5rem; }
  .monograph-content h3 { font-size: 1.02rem; line-height: 1.35; margin-top: 1.15rem; }
  .monograph-content .katex-display {
    font-size: 0.84rem; max-width: 100%; overflow-x: auto; overflow-y: hidden; background: var(--bg-elevated);
    border: 1px solid var(--border-hairline); border-radius: var(--radius-card); padding: 0.55rem 0.5rem; margin: 0.85rem 0; box-sizing: border-box;
  }
}
@media (max-width: 640px) {
  .bc-root, .bc-root-btn, .bc-sep, .bc-subject, .bc-full-word { display: none !important; }
  .pub-masthead-left, .pub-masthead-right { gap: 5px; } .pub-brand { display: inline-flex; font-size: 0.85rem; padding: 4px; }
  .doc-breadcrumb-bar { flex-wrap: nowrap; gap: 8px; } .bc-chapter-select { max-width: 185px; font-size: 0.76rem; }
}
@media (max-width: 520px) {
  .top-quick-search-wrap, .masthead-search-form { flex: 0 0 auto; min-width: 0; max-width: none; border: none; background: transparent; }
  .top-quick-search-input, .top-search-go-lbl { display: none; }
  .top-search-go-ico { display: inline-block; font-size: 0.85rem; }
  .top-quick-search-go { width: 32px; height: 32px; padding: 0; border: 1px solid var(--border-grid); border-radius: var(--radius-ui); background: var(--bg-canvas); color: var(--ink-primary); display: inline-flex; align-items: center; justify-content: center; }
}
