/* ============ aarnâ IYP Documentation — styles ============ */
/* Theme tokens. Light is default; [data-theme=dark] overrides.
   Palette + type mirror the aarnâ investor app: Lexend + teal identity. */
:root {
  --font-body: 'Lexend', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --bg: #f5f5f0;              /* shell — warm off-white (aarnâ marketing surface) */
  --bg-raised: #ffffff;
  --bg-sunken: #ecece5;
  --text: #0a3a3a;            /* deep teal ink — high-contrast reading */
  --text-soft: #4e6362;
  --text-faint: #8a9795;
  --border: #e4e4db;
  --accent: #1a8b85;          /* brand teal — single accent everywhere */
  --accent-soft: #e3f2ee;
  --accent-text: #125557;     /* deep teal — links + active states */
  --ok: #2e7d32;
  --warn: #c67700;
  --danger: #a1282b;
  --mark: #fce9a6;
  --shadow: 0 8px 30px rgba(10, 58, 58, .09);
  --radius: 12px;
  --topbar-h: 56px;
  --sidebar-w: 272px;
  --toc-w: 220px;
  --font-scale: 1;   /* reader-adjustable article text size (A− / A+) */
}
:root[data-theme='dark'] {
  --bg: #0e1514;
  --bg-raised: #16201f;
  --bg-sunken: #0a100f;
  --text: #d6e7e6;
  --text-soft: #a6c0be;
  --text-faint: #6e8482;
  --border: #2a3a38;
  --accent: #29a89f;
  --accent-soft: #14302d;
  --accent-text: #58cfc5;
  --mark: #3e4a12;
  --shadow: 0 8px 30px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
/* NOTE: never add `scroll-behavior: smooth` here — Chrome silently drops ALL
   programmatic scrolls (scrollTo/scrollIntoView) with it at non-100% browser
   zoom, which breaks search-result navigation and anchor links. */
body {
  margin: 0; font-family: var(--font-body); background: var(--bg); color: var(--text);
  font-size: 15.5px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
.msym {
  font-family: 'Material Symbols Rounded'; font-weight: normal; font-style: normal;
  font-size: 20px; line-height: 1; letter-spacing: normal; text-transform: none;
  display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr;
  font-variation-settings: 'opsz' 20, 'wght' 400;
  user-select: none;
}
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 12px; top: 12px; z-index: 100; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; }

/* ---------- topbar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 40;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: color-mix(in srgb, var(--bg-raised) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); white-space: nowrap; }
/* Wordmark is a single-colour asset; mask-recolour it to the live brand accent
   so it tracks the theme (deep teal in light, bright teal in dark). */
.brand-logo {
  display: block; height: 24px; aspect-ratio: 442 / 155; background-color: var(--accent);
  -webkit-mask: url("brand/logo.webp") no-repeat left center / contain;
  mask: url("brand/logo.webp") no-repeat left center / contain;
}
/* "IYP" badge — bordered muted pill, matching the app Logo component. */
.brand-badge {
  font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-faint); border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px;
}
.brand-sub { font-weight: 600; font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .14em; }

/* ---------- loaders ---------- */
/* Boot splash — shown until the first route has fully rendered. */
.boot {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center;
  justify-content: center; background: var(--bg); transition: opacity .28s ease;
}
.boot.done { opacity: 0; pointer-events: none; }
.boot-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.boot-logo {
  display: block; height: 38px; aspect-ratio: 442 / 155; background-color: var(--accent);
  -webkit-mask: url("brand/logo.webp") no-repeat center / contain;
  mask: url("brand/logo.webp") no-repeat center / contain;
}
.boot-bar { width: 120px; height: 2px; border-radius: 2px; background: var(--border); overflow: hidden; position: relative; }
.boot-bar::before {
  content: ''; position: absolute; inset: 0; width: 45%; border-radius: 2px;
  background: var(--accent); animation: loadslide 1s ease-in-out infinite;
}
/* Route-change progress — a 2px indeterminate bar over the topbar. */
.loadbar {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 210;
  pointer-events: none; opacity: 0; transition: opacity .18s ease; overflow: hidden;
}
.loadbar.active { opacity: 1; }
.loadbar::before {
  content: ''; display: block; height: 100%; width: 38%; border-radius: 2px;
  background: var(--accent); animation: loadslide .9s ease-in-out infinite;
}
@keyframes loadslide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(310%); }
}
.searchbox {
  flex: 1 1 auto; max-width: 460px; margin: 0 auto; height: 36px;
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text-faint); cursor: pointer; font-family: inherit; font-size: 13.5px;
}
.searchbox:hover { border-color: var(--accent); }
.searchbox-text { flex: 1; text-align: left; }
kbd {
  font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 5px;
  background: var(--bg-raised); border: 1px solid var(--border); color: var(--text-soft);
}
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.iconbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; min-width: 36px;
  padding: 0 8px; border: none; border-radius: 9px; background: transparent;
  color: var(--text-soft); cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
  text-decoration: none;
}
.iconbtn:hover { background: var(--bg-sunken); color: var(--text); }
.iconbtn .caret { font-size: 16px; margin-left: -4px; }
.raw-btn { border: 1px solid var(--border); }
.fontsize { display: flex; align-items: center; }
.fontsize .iconbtn { min-width: 32px; padding: 0 4px; }
.fontsize-reset {
  font-size: 11px; font-variant-numeric: tabular-nums; min-width: 42px;
  justify-content: center; color: var(--text-faint);
}
.raw-btn.active { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.nav-toggle { display: none; }

/* Ask AI dropdown */
.aimenu { position: relative; }
.aimenu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; z-index: 60;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; display: none;
}
.aimenu-panel.open { display: block; }
.aimenu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: none; background: none; border-radius: 8px; cursor: pointer; text-align: left;
  color: var(--text); font-family: inherit; font-size: 13.5px; font-weight: 500; text-decoration: none;
}
.aimenu-item:hover { background: var(--accent-soft); color: var(--accent-text); }
.aimenu-item .sub { display: block; font-size: 11.5px; color: var(--text-faint); font-weight: 400; }
.aimenu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- layout ---------- */
.layout { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w);
  overflow-y: auto; border-right: 1px solid var(--border); background: var(--bg);
  display: flex; flex-direction: column; z-index: 30;
}
.sidenav { flex: 1; padding: 18px 12px 12px; }
.sidenav-group { margin-bottom: 4px; }
.sidenav-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-faint); padding: 14px 10px 6px;
}
.sidenav a {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: 8px; color: var(--text-soft); text-decoration: none; font-size: 13.5px; font-weight: 500;
}
.sidenav a .msym { font-size: 18px; color: var(--text-faint); }
.sidenav a:hover { background: var(--bg-sunken); color: var(--text); }
.sidenav a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.sidenav a.active .msym { color: var(--accent); }
/* Left accent bar marks the current section. */
.sidenav a.active::before {
  content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); }
.sidebar-meta { font-size: 11.5px; color: var(--text-faint); line-height: 1.5; }
.sidebar-scrim { display: none; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); margin-right: var(--toc-w); }
.article { max-width: 820px; margin: 0 auto; padding: 36px 40px 24px; }
.pagefoot { max-width: 820px; margin: 0 auto; padding: 0 40px 60px; }

.toc {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: var(--toc-w);
  overflow-y: auto; padding: 28px 18px; font-size: 12.5px;
}
.toc-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--text-faint); margin-bottom: 8px; }
.toc a { display: block; padding: 4px 0 4px 10px; color: var(--text-soft); text-decoration: none; border-left: 2px solid var(--border); }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent-text); border-left-color: var(--accent); }

/* ---------- article typography ----------
   Sizes inside .article are em-based so the A−/A+ text-size control
   (--font-scale on the base size) scales everything proportionally. */
.article { font-size: calc(15.5px * var(--font-scale)); }
.article h1 { font-size: 1.94em; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; line-height: 1.25; }
.article .pagelede { font-size: 1.03em; color: var(--text-soft); margin: 0 0 26px; }
.article h2 {
  font-size: 1.35em; font-weight: 700; letter-spacing: -.01em; margin: 38px 0 12px;
  padding-top: 10px; scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.article h3 { font-size: 1.06em; font-weight: 700; margin: 26px 0 8px; scroll-margin-top: calc(var(--topbar-h) + 16px); }
.article p { margin: 10px 0; text-align: justify; text-justify: inter-word; }
.article ul, .article ol { margin: 10px 0; padding-left: 24px; }
.article li { margin: 5px 0; }
.article li::marker { color: var(--accent); }
.article a { color: var(--accent-text); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.article a:hover { border-bottom-color: var(--accent); }
/* Cross-reference to another section — vivid brand teal so it clearly reads as a link. */
.article a.xref {
  font-weight: 600; color: var(--accent);
  border-bottom-color: color-mix(in srgb, var(--accent) 50%, transparent);
}
.article a.xref:hover { border-bottom-color: var(--accent); }
.article code {
  font-family: var(--font-mono); font-size: .86em; background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: 6px; padding: 1.5px 6px;
}
.article pre {
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; overflow-x: auto; font-size: .84em; line-height: 1.55;
}
.article pre code { background: none; border: none; padding: 0; }
/* Shortened address chips linking to Etherscan. */
.article a.addr-link { border-bottom: none; }
.article a.addr-link code { color: var(--accent-text); font-weight: 500; cursor: pointer; white-space: nowrap; }
.article a.addr-link:hover code { border-color: var(--accent); background: var(--accent-soft); }
.article table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: .87em; display: block; overflow-x: auto; }
.article th, .article td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
.article th { background: var(--bg-sunken); font-weight: 600; white-space: nowrap; }
/* Two-column key/value tables authored with an empty header row: drop the blank row. */
.article table.noheader thead { display: none; }
/* GitBook-style hint block — tinted panel, brand rule, leading icon. */
.article blockquote {
  position: relative; margin: 18px 0; padding: 14px 18px 14px 46px;
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 10px; color: var(--text);
}
.article blockquote::before {
  content: 'info'; position: absolute; left: 15px; top: 14px;
  font-family: 'Material Symbols Rounded'; font-size: 20px; line-height: 1.5;
  color: var(--accent); font-variation-settings: 'opsz' 20, 'wght' 500;
}
.article blockquote p:first-child { margin-top: 0; }
.article blockquote p:last-child { margin-bottom: 0; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 30px 0; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- home cover ---------- */
/* On the landing route the content column goes full-bleed: no TOC rail, no max-width. */
body.is-home .toc { display: none; }
body.is-home .main { margin-right: 0; }
body.is-home .article, body.is-home .pagefoot { max-width: none; padding: 0; }
.cover { max-width: 1080px; margin: 0 auto; padding: 24px 40px 64px; }

.cover-hero {
  position: relative; overflow: hidden; border-radius: 18px; padding: 56px 48px;
  background: linear-gradient(135deg, #072b2b 0%, #0f4a48 46%, #1a8b85 132%);
}
/* Dot-grid motif, faded left-to-right. */
.cover-hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .6;
  background-image: radial-gradient(rgba(255,255,255,.12) 1.4px, transparent 1.5px);
  background-size: 22px 22px;
  -webkit-mask: linear-gradient(90deg, transparent, #000 55%); mask: linear-gradient(90deg, transparent, #000 55%);
}
/* Soft teal glow, top-right. */
.cover-hero::after {
  content: ''; position: absolute; right: -110px; top: -130px; width: 440px; height: 440px;
  pointer-events: none; background: radial-gradient(circle, rgba(41,207,197,.34), transparent 62%);
}
.cover-hero-inner { position: relative; max-width: 660px; }
.cover-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: #7fe3d9; margin-bottom: 16px; }
.cover-title { font-size: 2.7em; font-weight: 800; letter-spacing: -.025em; line-height: 1.08; color: #fff; margin: 0 0 14px; }
.cover-sub { font-size: 1.08em; line-height: 1.55; color: rgba(230,247,246,.82); margin: 0 0 26px; }

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
/* Scoped under .cover so these beat `.article a` colour on the dark hero. */
.cover .btn {
  display: inline-flex; align-items: center; height: 44px; padding: 0 22px; border-radius: 10px;
  font-weight: 600; font-size: 14.5px; text-decoration: none; border: 1px solid transparent; border-bottom: none;
}
.cover .btn-hero-primary { background: #fff; color: #0a3a3a; }
.cover .btn-hero-primary:hover { background: #d6f2ee; }
.cover .btn-hero-ghost { background: rgba(255,255,255,.10); color: #fff; border-color: rgba(255,255,255,.4); }
.cover .btn-hero-ghost:hover { background: rgba(255,255,255,.18); }

/* Body content is inset from the full-bleed hero and aligned to the hero text. */
.cover-body { padding: 30px 48px 0; }
.cover-intro { margin: 0; }
.cover-intro p { margin: 0 0 14px; line-height: 1.7; color: var(--text-soft); text-align: justify; }
.cover-intro p:first-child { font-size: 1.08em; color: var(--text); }
.cover-intro p:last-child { margin-bottom: 0; }

/* Product-at-a-glance facts (horizontal strip). */
.factstrip {
  display: grid; grid-template-columns: repeat(5, 1fr); margin: 24px 0 8px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--bg-raised); overflow: hidden;
}
.fact { padding: 15px 18px; display: flex; flex-direction: column; gap: 4px; border-left: 1px solid var(--border); }
.fact:first-child { border-left: none; }
.fact-k { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); }
.fact-v { font-size: 15px; font-weight: 700; color: var(--text); }

.cover-sec { margin-top: 40px; }
/* Even 3-up entry cards aligned to the cover width. */
.cover .chipgrid.cover-cards { grid-template-columns: repeat(3, 1fr); }
.cover-h2 { font-size: 1.28em; font-weight: 700; margin: 0 0 14px; }

.browsegrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px 18px; }
.browsecol-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 6px; }
.browsecol a { display: block; padding: 5px 0; color: var(--text-soft); text-decoration: none; font-size: 13.5px; border-bottom: none; }
.browsecol a:hover { color: var(--accent-text); }

/* section chips */
.chip { border-bottom: 1px solid var(--border); }
.chipgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 20px 0; }
.chip {
  display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-raised); text-decoration: none; color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.chip:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.chip .msym {
  color: var(--accent); font-size: 20px; flex: none; width: 34px; height: 34px;
  display: grid; place-items: center; background: var(--accent-soft); border-radius: 9px;
}
.chip b { display: block; font-size: 14px; margin-bottom: 2px; }
.chip span.desc { font-size: 12.5px; color: var(--text-soft); line-height: 1.45; display: block; }

/* ---------- FAQ accordion ---------- */
.faq-item {
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-raised);
  margin: 10px 0; overflow: hidden; transition: border-color .15s ease;
}
.faq-item:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.faq-item[open] { border-color: var(--accent); }
.faq-item summary {
  list-style: none; cursor: pointer; position: relative;
  padding: 14px 46px 14px 16px; font-weight: 600; color: var(--text);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: 'expand_more'; font-family: 'Material Symbols Rounded'; font-size: 22px;
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); transition: transform .2s ease;
}
.faq-item[open] summary::after { transform: translateY(-50%) rotate(180deg); color: var(--accent); }
.faq-item summary:hover { color: var(--accent-text); }
.faq-answer { padding: 0 16px 14px; color: var(--text-soft); }
.faq-answer p { margin: 0; }

/* ---------- diagram cards ---------- */
.diagram-card {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-raised);
  margin: 18px 0; overflow: hidden;
}
.diagram-card-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; color: var(--text-soft);
}
.diagram-card-body { padding: 14px; overflow-x: auto; display: flex; justify-content: center; min-height: 120px; align-items: center; cursor: zoom-in; }
.diagram-loading { color: var(--text-faint); font-size: 13px; }
.diagram-card-body svg { max-width: 100%; height: auto; }

/* diagram fullscreen modal */
.overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(10, 12, 20, .55);
  backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center;
}
.overlay[hidden], .toast[hidden] { display: none; }
.diagram-modal {
  width: min(96vw, 1400px); height: 92vh; margin-top: 3vh; display: flex; flex-direction: column;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.diagram-modal-bar {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 18px;
  border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px;
}
.diagram-modal-actions { display: flex; gap: 4px; }
/* Centering must be done with auto margins, NOT grid/flex `center` alignment:
   auto margins collapse to 0 when the diagram overflows, keeping every edge
   scrollable — alignment-based centering clips top/left unreachably. */
.diagram-modal-body { flex: 1; overflow: auto; display: flex; padding: 20px; cursor: grab; overscroll-behavior: contain; }
.diagram-modal-body:active { cursor: grabbing; }
.diagram-modal-body svg { display: block; margin: auto; flex: none; }

/* ---------- search ---------- */
.search-panel {
  width: min(94vw, 640px); margin-top: 9vh; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; max-height: 72vh;
}
.search-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.search-head .msym { color: var(--text-faint); }
#searchInput {
  flex: 1; border: none; outline: none; background: none; color: var(--text);
  font-family: inherit; font-size: 16px;
}
.search-results { overflow-y: auto; padding: 8px; overscroll-behavior: contain; }
/* While any overlay is open the page behind must not scroll. The lock must
   sit on <html> — body-only overflow:hidden still lets wheel events that
   start over a fixed overlay scroll the document in Chrome. */
html.overlay-open, html.overlay-open body { overflow: hidden; }
.search-hit {
  display: block; padding: 10px 12px; border-radius: 10px; cursor: pointer;
  text-decoration: none; color: var(--text);
}
.search-hit:hover, .search-hit.selected { background: var(--accent-soft); }
.search-hit .hit-row { display: flex; gap: 10px; align-items: flex-start; }
.search-hit .hit-icon { color: var(--text-faint); font-size: 18px; margin-top: 2px; }
.search-hit .hit-main { min-width: 0; flex: 1; }
.search-hit .hit-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--accent-text); }
.search-hit .hit-title { font-weight: 600; font-size: 14.5px; margin: 2px 0; }
.search-hit .hit-snippet { font-size: 12.5px; color: var(--text-soft); line-height: 1.5; margin-top: 2px; }
.search-empty { padding: 30px; text-align: center; color: var(--text-faint); font-size: 14px; }
.search-foot {
  display: flex; gap: 18px; padding: 9px 16px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-faint);
}

/* ---------- prev/next footer ---------- */
.prevnext { display: flex; gap: 14px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.prevnext a {
  flex: 1; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--text); background: var(--bg-raised);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.prevnext a:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.prevnext .dir { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--text-faint); }
.prevnext .ttl { font-weight: 600; font-size: 15px; color: var(--accent-text); }
.prevnext .next { text-align: right; }

/* ---------- raw view ---------- */
.raw-banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; margin: 0 0 22px;
  background: var(--accent-soft); color: var(--accent-text); border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
}
.article.raw { max-width: 900px; }
.article.raw h1 { font-size: 26px; margin-top: 46px; border-top: 2px solid var(--border); padding-top: 30px; }
.article.raw h1:first-of-type { margin-top: 0; border-top: none; padding-top: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow);
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .toc { display: none; }
  .main { margin-right: 0; }
}
@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.show { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 25; background: rgba(10,12,20,.4); }
  .main { margin-left: 0; }
  .article, .pagefoot { padding-left: 20px; padding-right: 20px; }
  .btn-label, .searchbox-text, #searchKbd, .fontsize { display: none; }
  .searchbox { flex: 0 0 auto; max-width: none; margin: 0 0 0 auto; border: none; background: transparent; }
  .brand-sub { display: none; }
}

@media (max-width: 920px) {
  .factstrip { grid-template-columns: repeat(2, 1fr); }
  .fact:nth-child(odd) { border-left: none; }
  .cover-body { padding: 26px 24px 0; }
}
@media (max-width: 680px) {
  .cover { padding: 16px 18px 48px; }
  .cover-hero { padding: 34px 22px; }
  .cover-body { padding: 22px 4px 0; }
  .cover-title { font-size: 1.9em; }
  .factstrip { grid-template-columns: 1fr; }
  .fact { border-left: none; border-top: 1px solid var(--border); }
  .fact:first-child { border-top: none; }
  .cover .chipgrid.cover-cards, .browsegrid { grid-template-columns: 1fr; }
}

/* ---------- print ---------- */
@media print {
  .topbar, .sidebar, .toc, .pagefoot, .overlay, .toast, .sidebar-scrim,
  .diagram-card-bar .iconbtn, .raw-banner { display: none !important; }
  .layout { padding-top: 0; }
  .main { margin: 0; }
  .article { max-width: none; padding: 0; }
  body { background: #fff; color: #111; font-size: 12px; }
  .article pre, .article code { background: #f5f5f5; border-color: #ddd; }
  /* Diagrams must each fit on one page or break-inside:avoid manufactures
     blank pages. Cap their height; viewBox keeps the aspect ratio. */
  .diagram-card { break-inside: avoid; border-color: #ccc; }
  .diagram-card-body { min-height: 0; padding: 8px; }
  .diagram-card-body svg {
    max-width: 100% !important; max-height: 150mm;
    width: auto !important; height: auto !important;
  }
  .article h2, .article h3 { break-after: avoid; }
  .article table { display: table; }
  a { color: #111 !important; border-bottom: none !important; }
}

