.theorem { scroll-margin-top: 1rem; }
a.lean_decl { overflow-wrap: anywhere; }
.displaymath { overflow-x: auto; max-width: 100%; padding-bottom: .3rem; }
@media (max-width: 650px) {
  .displaymath { overflow-x: auto; max-width: 100%; }
}

/* Follow the site's light/dark palette (assets/project-nav.css) instead of
   the fixed colors of the plasTeX white theme. */
:root { --bp-panel: #f2f2f2; --bp-hover: #e6e6e6; }
:root[data-theme="dark"] { --bp-panel: #1d2126; --bp-hover: #262c33; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bp-panel: #1d2126; --bp-hover: #262c33; }
}
body, .wrapper, .content, table, .tabular { background: var(--project-bg); color: var(--project-text); }
h1, h2, h3, h4, h1#doc_title, #doc_title a, #doc_title a:visited,
nav.prev_up_next a, a.icon, .local_toc ul a, ul.breadcrumbs a,
footer#footnotes h1, div.modal-content header h1 { color: var(--project-text); }
body > header, nav.prev_up_next, div.modal-content header, pre.verbatim { background: var(--bp-panel); color: var(--project-text); }
nav.toc, .toc ul li, .toc ul li.current { background: var(--project-bg); color: var(--project-text); }
nav.toc { border-color: var(--project-rule); }
.toc ul a:hover { background: var(--bp-hover); }
span.expand-toc, svg.close-toc { color: var(--project-muted); }
div.modal-content { background: var(--project-bg); border-color: var(--project-rule); }
.fbox, .framebox, hr { border-color: var(--project-text); color: var(--project-text); }
/* Dependency graph page. */
div#statements, #Legend dl, div.dep-modal-content, ul.tooltip_list {
  background: var(--bp-panel); color: var(--project-text);
}
div.bar { background: var(--project-text); }
#graph svg > g > polygon { fill: transparent; stroke: transparent; }
#graph svg .edge path, #graph svg .edge polygon { stroke: var(--project-muted); }
#graph svg .edge polygon { fill: var(--project-muted); }

/* Unnumbered sections inside a chapter render as h1; size them below the chapter title. */
.main-text > h1:not(:first-child) { font-size: 1.35rem; margin-top: 1.6rem; }

/* Lean declaration list in the dependency-graph popup: size it to the names
   (which are long) rather than a narrow column, wrapping only at the edge. */
ul.tooltip_list { width: max-content; max-width: min(60rem, 90vw); box-sizing: border-box; }
ul.tooltip_list a.lean_decl { overflow-wrap: break-word; word-break: normal; }

/* Consistent reading layout and contents panel on every blueprint. */
html { font-size: 16px; }
body { height: 100vh; height: 100dvh; line-height: 1.6; }
body > .project-links { position: relative; z-index: 60; }
div.wrapper { position: relative; min-height: 0; }
div.content { min-width: 0; padding: 28px 36px 36px; line-height: 1.65; }
div.content-wrapper { width: 100%; max-width: 78ch; margin: 0 auto; }
.main-text > h1:first-child, .titlepage h1 { font-size: 1.8rem; font-weight: 500; line-height: 1.3; margin: 0 0 1.25rem; }
.main-text > h1:not(:first-child), .main-text h2 { font-size: 1.35rem; font-weight: 500; line-height: 1.4; }
.main-text h3 { font-size: 1.1rem; font-weight: 500; line-height: 1.45; }
.main-text p { font-size: 1rem; line-height: 1.65; margin: .65rem 0; }
.main-text li, .local_toc li { font-size: 1rem; line-height: 1.6; }
.titlepage { margin: 1.5rem auto 2rem; max-width: 36rem; }
.titlepage .authors, .titlepage .author { font: 400 .95rem/1.5 var(--project-font); color: var(--project-muted); }
div[class$="_thmheading"] { flex-wrap: wrap; align-items: baseline; font-weight: 600; line-height: 1.6; gap: 0 .2rem; }
div[class$="_thmcontent"], div.proof_content { margin-left: .6rem; padding-left: .9rem; }
div.proof_heading { font-weight: 500; margin-top: .7rem; line-height: 1.6; }
a.lean_decl, ul.tooltip_list a { font-size: .9rem; }
.displaymath { margin: 1rem 0; }
nav.toc { width: 250px; max-width: 250px; flex: 0 0 250px; margin: 0; padding: 16px 10px; border-right: 1px solid var(--project-rule); }
nav.toc[hidden] { display: none !important; }
nav.toc:not([hidden]) { display: flex; }
nav.toc ul { min-width: 0; width: 100%; }
nav.toc ul li { min-width: 0; font-weight: 400; }
nav.toc ul a { max-width: 100%; padding: 8px 10px; font: 400 .86rem/1.45 var(--project-font); border-radius: 6px; }
nav.toc .toc_ref { margin-right: .25rem; color: var(--project-muted); }
nav.toc .toc_entry { font: inherit; }
nav.toc li.current > a { background: var(--bp-panel); color: var(--project-text); font-weight: 500; }
nav.toc .sub-toc-1 a { padding-left: 20px; font-size: .82rem; }
nav.toc .sub-toc-2 a { padding-left: 28px; font-size: .82rem; }
nav.toc span.expand-toc { font-size: .7rem; padding: 4px; width: 20px; min-height: 24px; height: auto; }
body.blueprint-ready > header { display: none; }
.sidebar-toggle { display: inline-flex; align-items: center; flex: 0 0 auto; gap: 6px; padding: 5px 7px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--project-muted); font: inherit; cursor: pointer; }
.sidebar-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.sidebar-toggle:hover { background: var(--bp-panel); color: var(--project-text); }
.sidebar-toggle:focus-visible { outline: 2px solid var(--project-link); outline-offset: 2px; }
.sidebar-backdrop { display: none; }
nav.prev_up_next { background: var(--project-bg); border: 1px solid var(--project-rule); border-bottom: 0; border-right: 0; border-radius: 8px 0 0; height: 2.5rem; z-index: 20; }
nav.prev_up_next a { font-size: 1rem; padding: .5rem .85rem; }
body > header { background: var(--project-bg); padding: 12px 24px; }
body > header h1#doc_title { font: 500 1.35rem/1.4 var(--project-font); }
#Legend span.title { font: 500 .95rem/1.4 var(--project-font); }
#Legend dl { z-index: 30; font-size: .85rem; max-width: min(30rem, 85vw); padding: 12px; border: 1px solid var(--project-rule); border-radius: 8px; }
@media (max-width: 900px) {
  div.content { padding: 22px 20px 48px; }
  nav.toc:not([hidden]) { position: absolute; inset: 0 auto 0 0; z-index: 40; width: min(280px, 85vw); max-width: none; background: var(--project-bg); box-shadow: 4px 0 20px rgba(0,0,0,.12); }
  .sidebar-backdrop:not([hidden]) { display: block; position: absolute; inset: 0; z-index: 30; padding: 0; border: 0; background: rgba(0,0,0,.25); }
  .project-links .author-link { display: none; }
}
@media (max-width: 600px) {
  .main-text > h1:first-child, .titlepage h1 { font-size: 1.5rem; }
  .project-links .sidebar-toggle span { display: none; }
  .project-links > a[aria-current="page"] { display: none; }
  .project-links { gap: 8px 12px; }
  div[class$="_thmcontent"], div.proof_content { margin-left: 0; padding-left: .6rem; }
}
