@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,400;6..72,600;6..72,800&display=swap");

:root {
  color-scheme: light dark;
  --paper: light-dark(#f3ead8, #1b1510);
  --paper-deep: light-dark(#e3d3b8, #120e09);
  --surface: light-dark(#fff9eb, #251e16);
  --surface-muted: light-dark(#eadfca, #322a20);
  --ink: light-dark(#15110d, #f1e7d4);
  --ink-soft: light-dark(#443a2f, #d9c9ae);
  --muted: light-dark(#756852, #a89676);
  --border: light-dark(#15110d, #f1e7d4);
  --on-accent: #15110d;
  --taxi: #f2bd22;
  --signal: light-dark(#df5035, #f0684e);
  --cyan: light-dark(#2da8a0, #4cc0b8);
  --green: light-dark(#5f8f3f, #8ab86b);
  --purple: light-dark(#8250df, #a371f7);
  --focus: light-dark(#0a6cff, #6ea8ff);
  --header-bg: light-dark(rgb(243 234 216 / 0.92), rgb(27 21 16 / 0.92));
  --grid-line: light-dark(rgb(21 17 13 / 0.045), rgb(241 231 212 / 0.05));
  --grid-line-soft: light-dark(rgb(21 17 13 / 0.035), rgb(241 231 212 / 0.04));
  --grid-dot: light-dark(rgb(21 17 13 / 0.022), rgb(241 231 212 / 0.028));
  --glow-taxi: light-dark(rgb(242 189 34 / 0.2), rgb(242 189 34 / 0.08));
  --glow-cyan: light-dark(rgb(45 168 160 / 0.14), rgb(45 168 160 / 0.07));
  --shadow-hard: 0.55rem 0.55rem 0 var(--ink);
  --shadow-soft: 0 1.4rem 4rem light-dark(rgb(21 17 13 / 0.14), rgb(0 0 0 / 0.5));
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", Verdana, Geneva, sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
  --measure: 72ch;
  --wide-measure: 94ch;
  --radius: 1.1rem;
  --speed: 220ms;
}

*, *::before, *::after { box-sizing: border-box; }
body[data-theme="dark"] { color-scheme: dark; }
body[data-theme="light"] { color-scheme: light; }
html { scroll-behavior: smooth; }
body, h1, h2, h3, p, figure, blockquote, dl, dd { margin: 0; }
img, video, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; }

body {
  background:
    radial-gradient(circle at 18% 12%, var(--glow-taxi), transparent 28rem),
    radial-gradient(circle at 90% 18%, var(--glow-cyan), transparent 24rem),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(180deg, var(--grid-line-soft) 1px, transparent 1px),
    radial-gradient(var(--grid-dot) 0.7px, transparent 0.7px),
    var(--paper);
  background-size: auto, auto, 3.2rem 3.2rem, 3.2rem 3.2rem, 5px 5px, auto;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.96rem + 0.18vw, 1.12rem);
  line-height: 1.68;
  min-height: 100vh;
}

a {
  color: var(--ink);
  text-decoration-color: var(--signal);
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.18em;
}

a:hover { color: var(--signal); }
a:focus-visible, button:focus-visible { outline: 4px solid var(--focus); outline-offset: 4px; }
::selection { background: var(--taxi); color: var(--on-accent); }

.cluster { align-items: center; display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; }
.stack > * + * { margin-top: clamp(1rem, 2vw, 1.5rem); }
.breakout, .wide-figure { max-width: var(--wide-measure) !important; }
.mono { font-family: var(--font-mono); }
.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}
.data-label, .eyebrow, .kicker {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}
.eyebrow { color: var(--signal); }
.data-label { color: var(--cyan); }
.lede {
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1rem + 1vw, 1.85rem);
  line-height: 1.28;
  max-width: 42rem;
}

.skip-link {
  background: var(--ink);
  border: 2px solid var(--taxi);
  color: var(--surface);
  left: 1rem;
  padding: 0.75rem 1rem;
  position: absolute;
  top: 1rem;
  transform: translateY(-150%);
  z-index: 40;
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  align-items: stretch;
  background: var(--header-bg);
  border-bottom: 3px solid var(--ink);
  display: grid;
  gap: 1rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  position: sticky;
  top: 0;
  z-index: 20;
}

@supports (backdrop-filter: blur(14px)) {
  .site-header { backdrop-filter: blur(14px); }
}

.masthead-mark {
  align-items: center;
  background: var(--taxi);
  border: 3px solid var(--ink);
  color: var(--on-accent);
  display: grid;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 3.2rem;
  padding: 0 0.8rem;
  transform: rotate(-2deg);
}

.site-title {
  color: var(--ink);
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 1rem + 1.5vw, 2.25rem);
  font-weight: 800;
  line-height: 0.95;
  text-decoration: none;
}
.site-description {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.25;
  margin-top: 0.25rem;
}
.header-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}
.language-switcher,
.version-switcher {
  align-self: center;
  position: relative;
}
.language-switcher summary,
.version-switcher summary {
  align-items: center;
  background: var(--surface);
  border: 3px solid var(--ink);
  cursor: pointer;
  display: flex;
  font-family: var(--font-mono);
  gap: 0.45rem;
  list-style: none;
  padding: 0.55rem 0.75rem;
  text-transform: uppercase;
}
.language-switcher summary::-webkit-details-marker,
.version-switcher summary::-webkit-details-marker { display: none; }
.language-switcher summary::after,
.version-switcher summary::after { content: "▾"; font-size: 0.72rem; }
.language-switcher__label,
.version-switcher__label { font-size: 0.68rem; letter-spacing: 0.1em; }
.language-switcher__current,
.version-switcher__current {
  background: var(--taxi);
  border: 2px solid var(--ink);
  color: var(--on-accent);
  font-size: 0.75rem;
  padding: 0.05rem 0.32rem;
}
.language-switcher ul,
.version-switcher ul {
  background: var(--surface);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-hard);
  list-style: none;
  margin: 0.35rem 0 0;
  min-width: 100%;
  padding: 0.35rem;
  position: absolute;
  right: 0;
  z-index: 22;
}
.language-switcher a,
.version-switcher a {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
  text-decoration: none;
}
.language-switcher a[aria-current="page"],
.version-switcher a[aria-current="page"] { background: var(--taxi); font-weight: 700; }
.version-switcher__alias {
  border: 2px solid var(--ink);
  font-size: 0.62rem;
  margin-left: 0.35rem;
  padding: 0 0.25rem;
  text-transform: uppercase;
}
.menu-toggle {
  align-self: center;
  background: var(--ink);
  border: 3px solid var(--ink);
  color: var(--surface);
  cursor: pointer;
  display: none;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 0.65rem 0.95rem;
  text-transform: uppercase;
}
.theme-select {
  align-self: center;
  background: var(--surface);
  border: 3px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
  display: none;
  font-family: var(--font-mono);
  /* >=1rem keeps iOS Safari from zooming the page on focus. */
  font-size: 1rem;
  padding: 0.55rem 0.5rem;
  text-transform: uppercase;
}
html.has-theme-select .theme-select { display: block; }

.site-search {
  align-self: center;
  display: none;
  position: relative;
}
html.has-search .site-search { display: block; }
.search-input {
  background: var(--surface);
  border: 3px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-mono);
  /* >=1rem keeps iOS Safari from zooming the page on focus. */
  font-size: 1rem;
  padding: 0.55rem 0.5rem;
  width: clamp(7rem, 18vw, 13rem);
}
.search-input::placeholder { color: var(--muted); }
.search-results {
  background: var(--surface);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-hard);
  list-style: none;
  margin: 0.35rem 0 0;
  max-height: 60vh;
  min-width: 16rem;
  overflow-y: auto;
  padding: 0.35rem;
  position: absolute;
  right: 0;
  z-index: 24;
}
.search-results a {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
  text-decoration: none;
}
.search-results a:hover,
.search-results a:focus-visible { background: var(--taxi); font-weight: 700; }
.search-no-results {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
}

.site-shell {
  display: grid;
  gap: clamp(1.2rem, 3vw, 3rem);
  grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr);
  margin: 0 auto;
  max-width: 96rem;
  padding: clamp(1rem, 3vw, 2.5rem);
}
.article-layout { grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr) minmax(12rem, 16rem); }
.content { min-width: 0; }

.sidebar {
  align-self: start;
  background: var(--surface);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-hard);
  max-height: calc(100vh - 7rem);
  overflow: auto;
  padding: 1rem;
  position: sticky;
  top: 6.2rem;
}
.home-link, .navigation-section a {
  display: block;
  padding: 0.45rem 0.55rem;
  text-decoration: none;
}
.home-link {
  background: var(--ink);
  color: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
  text-transform: uppercase;
}
.navigation-section { border-top: 2px solid var(--ink); padding: 0.95rem 0 0.15rem; }
.navigation-section + .navigation-section { margin-top: 0.75rem; }
.navigation-section h2 {
  font-family: var(--font-display);
  font-size: 1.18rem;
  line-height: 1;
  margin-bottom: 0.55rem;
}
.navigation-section ol { counter-reset: nav-item; list-style: none; margin: 0; padding: 0; }
.navigation-section li { counter-increment: nav-item; }
.navigation-section li a {
  color: var(--ink-soft);
  display: grid;
  font-size: 0.92rem;
  gap: 0.5rem;
  grid-template-columns: 2ch 1fr;
}
.navigation-section li a::before {
  color: var(--signal);
  content: counter(nav-item, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.navigation-section a[aria-current="page"], .home-link[aria-current="page"] {
  background: var(--taxi);
  color: var(--on-accent);
  font-weight: 700;
}
.article-toc {
  align-self: start;
  background: var(--surface);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-hard);
  max-height: calc(100vh - 7rem);
  overflow: auto;
  padding: 1rem;
  position: sticky;
  top: 6.2rem;
}
.article-toc ol, .mobile-toc ol { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.article-toc li + li, .mobile-toc li + li { margin-top: 0.45rem; }
.article-toc a, .mobile-toc a {
  color: var(--ink-soft);
  display: block;
  font-size: 0.9rem;
  line-height: 1.35;
  text-decoration: none;
}
.article-toc a:hover, .mobile-toc a:hover { color: var(--signal); }
.article-toc a[aria-current="true"] {
  background: var(--taxi);
  color: var(--on-accent);
  font-weight: 700;
}
.article-toc__link--level-3 { padding-left: 0.85rem; }

.mobile-toc {
  background: var(--surface);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-hard);
  display: none;
  margin-bottom: 1.4rem;
}
.mobile-toc summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  list-style: none;
  padding: 0.75rem 1rem;
}
.mobile-toc summary::-webkit-details-marker { display: none; }
.mobile-toc summary::after {
  content: "▾";
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.mobile-toc[open] summary::after { content: "▴"; }
.mobile-toc nav { border-top: 2px solid var(--ink); padding: 0.5rem 1rem 0.9rem; }

.hero, .article, .collection-card, .pager a, .not-found {
  background: var(--surface);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-hard);
}
.hero {
  margin-bottom: clamp(1.2rem, 3vw, 2.5rem);
  overflow: hidden;
  padding: clamp(1.5rem, 5vw, 5rem);
  position: relative;
}
.hero::after {
  background: var(--taxi);
  border: 3px solid var(--ink);
  color: var(--on-accent);
  content: "DATA / STORY / OPS";
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 0.45rem 0.8rem;
  position: absolute;
  right: clamp(1rem, 3vw, 2rem);
  top: clamp(1rem, 3vw, 2rem);
  transform: rotate(2deg);
}
.hero h1, .article h1 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 0.88;
  margin: 0.35rem 0 1rem;
  overflow-wrap: break-word;
}
.hero h1 {
  font-size: clamp(3rem, 9vw, 8rem);
  max-width: 11ch;
}
.article h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  max-width: 18ch;
}
.article { overflow: clip; }
.article-header {
  background:
    linear-gradient(135deg, transparent 0 68%, rgb(242 189 34 / 0.42) 68% 100%),
    var(--surface);
  border-bottom: 3px solid var(--ink);
  padding: clamp(1.5rem, 5vw, 4rem);
}
.article-body { padding: clamp(1.2rem, 4vw, 3.5rem); }
.article-body > * { max-width: var(--measure); }
.article-body h2, .article-body h3 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1;
  margin-top: clamp(2rem, 4vw, 3rem);
}
.article-body h2 { font-size: clamp(2rem, 4vw, 3.5rem); }
.article-body h3 { font-size: clamp(1.45rem, 3vw, 2.25rem); }
.article-body .headerlink {
  margin-inline-start: 0.4em;
  opacity: 0;
  text-decoration: none;
}
.article-body :is(:hover, :target) > .headerlink,
.article-body .headerlink:focus-visible { opacity: 1; }
.article-body p, .article-body li { color: var(--ink-soft); }
.article-body blockquote {
  border-left: 0.55rem solid var(--signal);
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  line-height: 1.2;
  padding-left: 1rem;
}
.article-body .markdown-alert {
  border: 2px solid var(--border);
  border-left: 0.55rem solid var(--alert-accent, var(--focus));
  padding: 0.9rem 1rem;
}
.article-body .markdown-alert-note { --alert-accent: var(--focus); }
.article-body .markdown-alert-tip { --alert-accent: var(--green); }
.article-body .markdown-alert-important { --alert-accent: var(--purple); }
.article-body .markdown-alert-warning { --alert-accent: var(--taxi); }
.article-body .markdown-alert-caution { --alert-accent: var(--signal); }
.article-body .markdown-alert-title {
  align-items: center;
  color: var(--alert-accent, var(--focus));
  display: flex;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  gap: 0.45rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}
.article-body .markdown-alert-icon { flex: 0 0 auto; }
.article-body table {
  border-collapse: collapse;
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
.article-body th, .article-body td {
  border: 2px solid var(--ink);
  padding: 0.55rem 0.7rem;
  text-align: left;
  white-space: nowrap;
}
.article-body th { background: var(--taxi); color: var(--on-accent); font-family: var(--font-mono); font-size: 0.82rem; }

.not-found {
  padding: clamp(1.5rem, 5vw, 5rem);
  text-align: center;
}
.not-found h1 {
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 8rem);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 0.88;
  margin: 0.35rem 0 1rem;
}
.not-found a { font-family: var(--font-mono); font-weight: 600; }

.source-panel, .media-frame, .notebook-cell, .data-callout, .chart-frame, .diagram-frame, .mermaid-diagram {
  background: var(--surface);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-hard);
  max-width: var(--wide-measure) !important;
}
/* The rendered svg carries a fixed height attribute; auto lets
   max-width scale it proportionally inside narrow viewports. */
.mermaid-diagram svg { height: auto; margin: 0 auto; }
.source-panel figcaption, .media-frame figcaption {
  align-items: center;
  border-bottom: 3px solid var(--ink);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
}
.source-panel__path {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}
.article-body pre, .notebook-input pre, .notebook-output pre, .source-panel pre {
  background: #17130f;
  color: #f8ead0;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.62;
  margin: 0;
  max-width: 100%;
  overflow: auto;
  padding: 1rem;
}
.article-body code { font-family: var(--font-mono); }
.article-body pre code, .notebook-input pre code,
.notebook-output pre code, .source-panel pre code {
  white-space: pre;
}
.article-body :not(pre) > code {
  background: rgb(242 189 34 / 0.32);
  border: 1px solid var(--ink);
  padding: 0.08rem 0.25rem;
}
.code-frame { position: relative; }
.code-copy-button {
  background: var(--surface);
  border: 2px solid var(--ink);
  cursor: pointer;
  display: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.22rem 0.35rem;
  position: absolute;
  right: 0.55rem;
  top: 0.55rem;
  z-index: 1;
}
html.has-code-copy .code-copy-button { display: block; }
.code-copy-button::after {
  background-color: var(--ink);
  content: "";
  display: block;
  height: 0.95rem;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Crect x='8' y='8' width='13' height='13' rx='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E");
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
  width: 0.95rem;
}
.code-copy-button:hover, .code-copy-button:focus-visible { background: var(--taxi); }
.code-copy-button.is-copied::after { display: none; }
@media (hover: hover) {
  html.has-code-copy .code-copy-button { opacity: 0; }
  html.has-code-copy .code-frame:hover .code-copy-button,
  html.has-code-copy .code-copy-button:focus-visible { opacity: 1; }
}
.media-frame video, .media-frame img, .notebook-image img,
.article-body > img, .article-body > video {
  background: var(--ink);
  height: auto;
  width: 100%;
}
.video-frame { background: var(--ink); }
.video-frame figcaption { background: var(--surface); }
.notebook-cell { overflow: hidden; }
.notebook-cell__header {
  align-items: center;
  background: var(--taxi);
  border-bottom: 3px solid var(--ink);
  color: var(--on-accent);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
}
.notebook-cell__index, .notebook-output__label {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.notebook-output { border-top: 3px solid var(--ink); background: #211b15; color: #f8ead0; }
.notebook-output__label {
  background: var(--cyan);
  border-bottom: 3px solid var(--ink);
  color: var(--on-accent);
  display: block;
  padding: 0.45rem 0.8rem;
}
.notebook-output pre { background: transparent; }
/* html-manager renders widget controls unstyled, so they inherit the UA
   default (~13px) — under 16px iOS Safari zooms the page on focus. The
   !important mirrors the embed-frame rule above: widget styles inject at
   runtime and would otherwise win on source order. */
.jupyter-widgets-container :is(input, select, textarea) { font-size: 1rem !important; }
.notebook-image { background: var(--surface); }
.data-callout, .chart-frame, .diagram-frame { padding: clamp(1rem, 3vw, 2rem); }
.data-callout { background: linear-gradient(135deg, rgb(45 168 160 / 0.18), var(--surface) 45%); }

.section-heading {
  border-bottom: 3px solid var(--ink);
  margin-bottom: 1rem;
  padding-bottom: 0.7rem;
}
.section-heading h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.95;
}
.cards {
  display: grid;
  gap: clamp(1rem, 2vw, 1.5rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}
.collection-card { min-height: 19rem; padding: 1rem; position: relative; }
.collection-card::after {
  background: var(--signal);
  border: 3px solid var(--ink);
  content: "";
  height: 2.2rem;
  position: absolute;
  right: 1rem;
  top: -0.75rem;
  transform: rotate(5deg);
  width: 4.2rem;
}
.collection-card h3 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 0.92;
  margin: 0.55rem 0 1.25rem;
}
.collection-card ol {
  border-top: 2px solid var(--ink);
  counter-reset: collection-page;
  list-style: none;
  margin: 0;
  padding: 0.75rem 0 0;
}
.collection-card li {
  counter-increment: collection-page;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: 2ch 1fr;
}
.collection-card li + li { margin-top: 0.45rem; }
.collection-card li::before {
  color: var(--signal);
  content: counter(collection-page, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
}
.page-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  gap: 0.5rem 2rem;
  justify-content: space-between;
  margin-top: 3rem;
}
.page-meta p { margin: 0; }
.edit-link {
  align-items: center;
  color: inherit;
  display: inline-flex;
  gap: 0.45em;
  text-decoration: none;
}
.edit-link:hover, .edit-link:focus-visible { color: var(--ink); }
.edit-link::before {
  background-color: currentColor;
  content: "";
  display: block;
  height: 0.95em;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z'/%3E%3C/svg%3E");
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
  width: 0.95em;
}
.pager {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  margin-top: 1.2rem;
}
.pager a { padding: 1rem; text-decoration: none; }
.pager span {
  color: var(--signal);
  display: block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.site-footer {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 1rem clamp(1rem, 4vw, 3rem) 2rem;
  text-align: center;
}

.back-to-top {
  background: var(--ink);
  border: 3px solid var(--ink);
  color: var(--surface);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  left: 50%;
  letter-spacing: 0.12em;
  padding: 0.45rem 0.8rem;
  position: fixed;
  top: 5.75rem;
  transform: translateX(-50%);
  /* Below the sticky header (z 20), above unstacked content; the z 30
     layer is pinned out of this stylesheet by a regression test. */
  z-index: 15;
}
/* hidden ships in markup; an author display rule would beat the UA's
   [hidden] = display:none, so the guard stays explicit. */
.back-to-top[hidden] { display: none; }

@media (max-width: 58rem) {
  .site-header { grid-template-columns: auto 1fr auto; }
  /* 44px touch-target floor (Apple HIG / Android 48dp) for tap chrome. */
  .theme-select, .mobile-toc summary { min-height: 2.75rem; }
  .menu-toggle { display: inline-flex; }
  .site-shell { display: block; }
  .sidebar { display: none; margin: 1rem 0 1.4rem; max-height: none; position: static; }
  .sidebar.is-open { display: block; }
  .article-toc { display: none; }
  .mobile-toc { display: block; }
  .hero::after { position: static; display: inline-block; margin-top: 1rem; }
}

@media (max-width: 40rem) {
  .site-header { gap: 0.65rem; padding: 0.7rem 0.85rem; }
  /* The locale badge + caret alone keep the switcher readable; dropping the
     word label frees ~2.5rem the pt-BR header needed at 320px. */
  .language-switcher__label,
  .version-switcher__label { display: none; }
  /* The actions track floors at its widest child; both caps keep the pt-BR
     header inside 320px. The select's closed label truncates — the opened
     option list still renders full text. */
  .theme-select { max-width: 6.5rem; }
  .search-input { width: clamp(5.5rem, 18vw, 13rem); }
  .masthead-mark { min-height: 2.8rem; padding: 0 0.6rem; }
  .site-description { display: none; }
  .hero h1 { font-size: clamp(2.3rem, 13.5vw, 3.7rem); }
  .article h1 { font-size: clamp(2rem, 8vw, 3rem); }
  .article-body { padding: 1rem; }
  .source-panel, .media-frame, .notebook-cell { box-shadow: 0.35rem 0.35rem 0 var(--ink); }
}

@media (prefers-reduced-motion: no-preference) {
  .skip-link, a, button {
    transition: color var(--speed), background-color var(--speed), transform var(--speed);
  }
  .collection-card:hover, .pager a:hover { transform: translate(-0.18rem, -0.18rem); }
  .has-reveal .story-step, .has-reveal .media-frame, .has-reveal .notebook-cell {
    transform: translateY(1.1rem);
    transition: transform 520ms ease;
  }
  .has-reveal .story-step.is-visible,
  .has-reveal .media-frame.is-visible,
  .has-reveal .notebook-cell.is-visible {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Custom Scrollbars */
html {
  scrollbar-color: var(--muted) var(--paper-deep);
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 0.55rem;
  height: 0.55rem;
}

::-webkit-scrollbar-track {
  background: var(--paper-deep);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 4px;
  border: 1px solid var(--paper-deep);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-soft);
}

/* Pre / Code Scrollbars */
pre {
  scrollbar-color: var(--muted) #17130f;
}

pre::-webkit-scrollbar-track {
  background: #17130f;
  border-radius: 4px;
}

pre::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-color: #17130f;
}

pre::-webkit-scrollbar-thumb:hover {
  background: #f8ead0;
}

/* KaTeX math blocks horizontal scroll on overflow */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5em 0;
  max-width: 100%;
}

/* Paper output: force the light scheme — every themed color resolves through
   light-dark() per the element's color-scheme, so a stored dark pick or a
   dark OS would otherwise print cream ink on white paper. Nav/pager/toc drop
   out, the article takes the full width, and code collapses to ink and wraps
   instead of clipping. */
@media print {
  :root {
    color-scheme: light;
    --shadow-hard: none;
    --shadow-soft: none;
  }
  body[data-theme] { color-scheme: light; }
  body { background: none; }

  .skip-link, .header-actions, .sidebar, .article-toc, .mobile-toc, .pager,
  .article-body .headerlink, .code-copy-button, .back-to-top,
  .edit-link { display: none; }

  .site-header { position: static; }
  .site-shell { display: block; max-width: none; padding: 0; }
  .article { overflow: visible; }
  .article-body > * { max-width: none; }

  .article-body :is(h1, h2, h3, h4, h5, h6) { break-after: avoid; }
  .article-body :is(p, li) { orphans: 2; widows: 2; }
  pre, figure, .notebook-cell, .data-callout, .collection-card,
  .chart-frame, .diagram-frame, blockquote, .markdown-alert, tr { break-inside: avoid; }

  .article-body pre, .notebook-input pre, .notebook-output pre,
  .source-panel pre {
    background: transparent;
    color: var(--ink);
    overflow: visible;
    white-space: pre-wrap;
  }
  .notebook-output { background: transparent; color: var(--ink); }
  /* gruvbox-dark lands as inline styles (noclasses=True); only !important
     beats them, and light-on-dark tokens are unreadable on paper. */
  .highlight-token { color: var(--ink) !important; }

  .article-body table { display: table; overflow-x: visible; }
  .article-body th, .article-body td { white-space: normal; }
  .katex-display { overflow-x: visible; }
  /* has-reveal leaves unviewed elements translated; paper has no scroll. */
  .story-step, .media-frame, .notebook-cell { transform: none; }
  .hero::after, .collection-card::after { content: none; }
}