/* Distill publication article template modeled on the al-folio / ICLR Distill style.
   Loaded only on articles/posts alongside site.css and article-audio.css. */

.ak-distill-main {
  --global-bg-color: #ffffff;
  --global-text-color: #000000;
  --global-text-color-light: #828282;
  --global-theme-color: var(--ak-link, #2698ba);
  --global-hover-color: #1688aa;
  --global-divider-color: rgba(0, 0, 0, 0.1);
  --global-distill-app-color: #828282;
  --global-code-bg-color: rgba(38, 152, 186, 0.05);
  --global-back-to-top-bg-color: rgba(0, 0, 0, 0.4);
  --global-back-to-top-text-color: #ffffff;
  --d-font: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --d-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-family: var(--d-font);
  font-weight: 300;
  color: var(--global-text-color);
  background: var(--global-bg-color);
}

/* Override site.css #main container so Distill 12-column bands span edge-to-edge */
#main.ak-distill-main {
  display: block;
  max-width: none;
  margin: 0;
  padding: 0;
}

.ak-distill-article {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* Top reading progress bar (matches reference <progress id="progress">) */
.d-reading-progress {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  height: 2px;
  z-index: 45;
  pointer-events: none;
  background: transparent;
}

.d-reading-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--global-theme-color, #2698ba);
  transform-origin: left center;
  transform: scaleX(0);
  will-change: transform;
}

/* ==========================================================================
   Official Distill v2 Centered 12-Column Grid across all article bands
   ========================================================================== */
.d-title,
.d-byline,
.page__content.d-article,
.d-appendix {
  display: grid;
  width: 100%;
  box-sizing: border-box;
  grid-template-columns:
    [screen-start] 16px
    [page-start kicker-start middle-start text-start] minmax(0, 1fr)
    [text-end middle-end page-end gutter-end] 16px
    [screen-end];
  column-gap: 0;
}

.d-title > *,
.d-byline > *,
.page__content.d-article > *,
.d-appendix > * {
  grid-column: text-start / text-end;
  min-width: 0;
}

@media (min-width: 768px) {
  .d-title,
  .d-byline,
  .page__content.d-article,
  .d-appendix {
    grid-template-columns:
      [screen-start] minmax(24px, 1fr)
      [page-start kicker-start middle-start text-start] repeat(8, minmax(0, 68px))
      [text-end middle-end page-end gutter-end] minmax(24px, 1fr)
      [screen-end];
    column-gap: 20px;
  }
}

@media (min-width: 1025px) {
  .d-title,
  .d-byline,
  .page__content.d-article,
  .d-appendix {
    grid-template-columns:
      [screen-start] minmax(16px, 1fr)
      [page-start kicker-start] 48px
      [middle-start] 48px
      [text-start kicker-end] repeat(8, 48px)
      [text-end gutter-start] 48px
      [middle-end] 48px
      [page-end gutter-end] minmax(16px, 1fr)
      [screen-end];
    column-gap: 24px;
  }
}

@media (min-width: 1180px) {
  .d-title,
  .d-byline,
  .page__content.d-article,
  .d-appendix {
    grid-template-columns:
      [screen-start] 1fr
      [page-start kicker-start] 60px
      [middle-start] 60px
      [text-start kicker-end] repeat(8, 60px)
      [text-end gutter-start] 60px
      [middle-end] 60px
      [page-end gutter-end] 1fr
      [screen-end];
    column-gap: 32px;
  }
}

/* ==========================================================================
   1. d-title — Centered 50px bold headline + light 19.2px description
   ========================================================================== */
.d-title {
  padding: 4rem 0 1.75rem;
}

.d-eyebrow-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 1.25rem;
}

.ak-distill-article .d-breadcrumb {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--global-text-color-light);
}

.ak-distill-article .d-breadcrumb a {
  color: var(--global-text-color-light);
  text-decoration: none;
}

.ak-distill-article .d-breadcrumb a:hover {
  color: var(--global-theme-color);
  text-decoration: underline;
}

.d-article-type {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--global-theme-color);
}

.ak-distill-article .d-headline {
  margin: 0 0 1rem;
  font-family: var(--d-font);
  font-size: clamp(32px, 4.2vw, 50px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--global-text-color);
  overflow-wrap: break-word;
}

.d-subtitle {
  margin: 0;
  font-family: var(--d-font);
  font-size: clamp(17px, 1.5vw, 19.2px);
  font-weight: 300;
  line-height: 1.55;
  color: var(--global-text-color);
}

/* ==========================================================================
   2. d-byline — Clean academic metadata strip
   ========================================================================== */
.d-byline {
  border-top: 1px solid var(--global-divider-color);
  padding: 1.4rem 0;
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--global-text-color);
}

.d-byline__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem 1.75rem;
  align-items: start;
}

.d-byline__col {
  min-width: 0;
}

.d-byline__col h3 {
  margin: 0 0 0.35rem;
  font-family: var(--d-font);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.55);
  line-height: 1.3;
}

.d-byline__col p {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 300;
  line-height: 1.55;
  color: var(--global-text-color);
}

.d-byline__author-name {
  font-weight: 300;
}

.d-byline__col a {
  color: var(--global-text-color);
  text-decoration: none;
  border-bottom: none;
}

.d-byline__col a:hover {
  color: var(--global-hover-color);
  text-decoration: none;
}

.d-byline__paper-link {
  color: var(--global-theme-color) !important;
  font-weight: 400;
}

.d-byline__paper-link:hover {
  text-decoration: underline !important;
}

.d-byline__sub {
  font-size: 0.75rem !important;
  color: var(--global-text-color-light) !important;
  margin-top: 0.15rem !important;
}

/* ==========================================================================
   3. d-article — Main Distill article grid, TOC, prose, figures, tables
   ========================================================================== */
.page__content.d-article {
  border-top: 1px solid var(--global-divider-color);
  padding: 2.5rem 0 3.5rem;
  font-family: var(--d-font);
  font-size: 1.06rem;
  font-weight: 300;
  line-height: 1.7;
  color: var(--global-text-color);
  overflow-wrap: break-word;
}

/* Contents TOC & Side Author Profile — matches al-folio-distill.css */
.page__content.d-article > .d-contents {
  grid-column: text-start / text-end;
  padding: 1rem 1.25rem;
  margin: 0 0 1.75rem;
  border: 1px solid var(--global-divider-color);
  background: var(--global-bg-color);
}

.d-side-profile {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 0.25rem 0.9rem;
  align-items: center;
}

.d-side-profile + .d-contents__nav:not([hidden]) {
  margin-top: 1.15rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--global-divider-color);
}

.d-side-profile__portrait {
  display: block;
  grid-row: 1 / span 2;
  border-bottom: none !important;
}

.d-side-profile__portrait img {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
  object-position: center 24%;
  border-radius: 6px;
}

.d-side-profile__info {
  min-width: 0;
}

.d-side-profile__name {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--global-text-color);
}

.d-side-profile__name a {
  color: var(--global-text-color) !important;
  border-bottom: none !important;
  text-decoration: none !important;
}

.d-side-profile__name a:hover {
  color: var(--global-theme-color) !important;
}

.d-side-profile__role,
.d-side-profile__location {
  font-size: 0.78rem;
  font-weight: 300;
  line-height: 1.45;
  color: var(--global-text-color-light);
}

.d-side-profile__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  line-height: 1.4;
}

.d-side-profile__links a {
  color: var(--global-theme-color) !important;
  font-weight: 400;
  border-bottom: none !important;
  text-decoration: none !important;
}

.d-side-profile__links a:hover {
  color: var(--global-hover-color) !important;
  text-decoration: underline !important;
}

.d-contents__nav h3 {
  margin: 0 0 0.85rem;
  font-family: var(--d-font);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--global-text-color);
}

.d-contents__list > div {
  display: block;
  margin-bottom: 0.65rem;
  line-height: 1.4;
}

.d-contents__list > div:last-child {
  margin-bottom: 0;
}

.d-contents__list a {
  display: inline;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--global-theme-color) !important;
  text-decoration: none !important;
  border-bottom: none !important;
}

.d-contents__list a:hover,
.d-contents__list a.is-active,
.d-contents__list a[aria-current="location"] {
  border-bottom: 1px solid var(--global-text-color) !important;
  color: var(--global-hover-color) !important;
}

.d-contents__sublist {
  list-style: none;
  margin: 0.3rem 0 0.4rem;
  padding-left: 1rem;
}

.d-contents__sublist li {
  margin-bottom: 0.25rem;
  line-height: 1.35;
}

.d-contents__sublist a {
  font-size: 0.8rem;
  font-weight: 400;
}

@media (min-width: 1025px) {
  .page__content.d-article > .d-contents {
    grid-column: 1 / 4;
    grid-row: 1 / span var(--d-toc-span, 6);
    align-self: start;
    justify-self: end;
    width: max(70%, 240px);
    max-width: 300px;
    margin: 0;
    padding: 0 2.25rem 0 1.25rem;
    border: 0;
    border-right: 1px solid var(--global-divider-color);
  }

  .d-side-profile {
    display: block;
  }

  .d-side-profile__portrait {
    margin-bottom: 0.7rem;
  }

  .d-side-profile__portrait img {
    width: 72px;
    height: 72px;
    border-radius: 6px;
  }

  .d-side-profile__links {
    margin-top: 0.55rem;
    gap: 0.2rem 0.75rem;
  }
}

/* Prose typography matching reference (Roboto 300 body, bold 600/700 headings) */
.page__content.d-article p {
  margin: 0 0 1.25rem;
  font-weight: 300;
  color: var(--global-text-color);
}

.page__content.d-article strong,
.page__content.d-article b {
  font-weight: 600;
  color: var(--global-text-color);
}

.page__content.d-article a {
  color: var(--global-theme-color);
  text-decoration: none;
  border-bottom: 1px solid rgba(38, 152, 186, 0.35);
}

.page__content.d-article a:hover {
  color: var(--global-hover-color);
  border-bottom-color: var(--global-theme-color);
  text-decoration: none;
}

/* Headings */
.page__content.d-article h2 {
  position: relative;
  margin: 2.5rem 0 1.25rem;
  padding: 0 0 0.5rem;
  border-bottom: 1px solid var(--global-divider-color);
  font-family: var(--d-font);
  font-size: clamp(26px, 2.8vw, 36px);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--global-text-color);
}

.page__content.d-article > h2:first-of-type {
  margin-top: 0.4rem;
}

.page__content.d-article h3 {
  position: relative;
  margin: 2rem 0 0.85rem;
  font-family: var(--d-font);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--global-text-color);
}

.page__content.d-article h4 {
  margin: 1.6rem 0 0.6rem;
  font-family: var(--d-font);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--global-text-color);
}

.page__content.d-article h5 {
  margin: 1.4rem 0 0.5rem;
  font-family: var(--d-font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--global-text-color);
}

/* Heading deep-link anchors */
.page__content.d-article .d-heading-anchor {
  margin-left: 0.35em;
  color: var(--global-text-color-light);
  border-bottom: none;
  font-weight: 300;
  font-size: 0.72em;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.page__content.d-article :is(h2, h3):hover .d-heading-anchor,
.page__content.d-article .d-heading-anchor:focus-visible {
  opacity: 1;
}

.page__content.d-article .d-heading-anchor:hover {
  color: var(--global-theme-color);
}

/* Lists */
.page__content.d-article ul,
.page__content.d-article ol {
  margin: 0 0 1.35rem;
  padding-left: 1.5rem;
}

.page__content.d-article li {
  margin-bottom: 0.5rem;
  font-weight: 300;
  line-height: 1.7;
  color: var(--global-text-color);
}

.page__content.d-article li > p {
  margin-bottom: 0.5rem;
}

/* Horizontal rules */
.page__content.d-article hr {
  margin: 2.25rem 0;
  border: 0;
  border-top: 1px solid var(--global-divider-color);
}

/* Blockquotes — exact al-folio / Distill style (2px theme border, italic 1.15rem) */
.page__content.d-article blockquote {
  margin: 1.75rem 0;
  padding: 0.65rem 1.25rem;
  background: var(--global-bg-color);
  border-left: 2px solid var(--global-theme-color);
  font-size: 1.15rem;
  font-weight: 300;
  font-style: italic;
  line-height: 1.65;
  color: rgba(0, 0, 0, 0.7);
}

.page__content.d-article blockquote p {
  color: inherit;
  margin-bottom: 0.6rem;
}

.page__content.d-article blockquote p:last-child {
  margin-bottom: 0;
}

/* "In brief" summary callout styled cleanly in reference aesthetic */
.page__content.d-article .ak-article-summary {
  margin: 0 0 2rem;
  padding: 1rem 1.35rem;
  border: 0;
  border-left: 2px solid var(--global-theme-color);
  background: var(--global-code-bg-color);
  border-radius: 0 4px 4px 0;
}

.page__content.d-article .ak-article-summary > p:first-child {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--global-theme-color);
}

.page__content.d-article .ak-article-summary ul {
  margin: 0;
  padding-left: 1.25rem;
}

.page__content.d-article .ak-article-summary li {
  font-size: 0.96rem;
  line-height: 1.6;
  margin-bottom: 0.45rem;
}

.page__content.d-article .ak-article-summary li:last-child {
  margin-bottom: 0;
}

/* Audio narration bar harmonized with reference theme */
.page__content.d-article .ak-article-listen {
  margin: 0 0 1.75rem;
}

.page__content.d-article .ak-listen-player {
  padding: 12px 16px;
  border: 1px solid var(--global-divider-color);
  border-radius: 4px;
  background: var(--global-bg-color);
}

.page__content.d-article .ak-article-listen.is-playing .ak-listen-player {
  border-color: var(--global-theme-color);
}

.page__content.d-article .ak-listen-play-btn,
.page__content.d-article .ak-listen-progress-fill,
.page__content.d-article .ak-listen-wave span {
  background: var(--global-theme-color);
}

.page__content.d-article .ak-listen-status,
.page__content.d-article .ak-listen-time {
  color: var(--global-text-color-light);
}

.page__content.d-article .ak-listenable {
  border-left: 2px solid transparent;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.page__content.d-article .ak-speaking {
  border-left-color: var(--global-theme-color);
  padding-left: 12px;
  background: var(--global-code-bg-color);
}

/* Figures & symmetric Distill breakouts */
.page__content.d-article figure {
  display: block;
  margin: 2rem 0;
}

.page__content.d-article figure img,
.page__content.d-article figure video {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 0.75rem;
  border: 0;
  border-radius: 2px;
}

.page__content.d-article figure > a {
  display: block;
  border-bottom: none;
}

.page__content.d-article figcaption,
.page__content.d-article .caption {
  margin: 0.75rem auto 1.5rem;
  max-width: 704px;
  font-family: var(--d-font);
  font-size: 0.875rem;
  font-weight: 300;
  line-height: 1.55;
  color: rgba(0, 0, 0, 0.72);
  text-align: center;
}

.page__content.d-article figcaption strong,
.page__content.d-article .caption strong {
  font-weight: 600;
  color: var(--global-text-color);
}

.page__content.d-article figcaption a {
  color: var(--global-theme-color);
  border-bottom: none;
}

.page__content.d-article figcaption a:hover {
  text-decoration: underline;
}

/* Symmetric wide spans on the 12-column Distill grid */
.page__content.d-article > .ak-article-figure--wide,
.page__content.d-article > .ak-figure-grid,
.page__content.d-article > .l-page {
  grid-column: page-start / page-end;
}

.page__content.d-article > .ak-method-grid,
.page__content.d-article > .l-body-outset {
  grid-column: middle-start / middle-end;
}

.page__content.d-article > .l-screen {
  grid-column: screen-start / screen-end;
}

.page__content.d-article > .d-aside,
.page__content.d-article > aside.l-gutter {
  margin: 1rem 0 1.5rem;
  padding: 0.75rem 1rem;
  border-left: 2px solid var(--global-divider-color);
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--global-text-color-light);
}

@media (min-width: 1025px) {
  .page__content.d-article > .d-aside,
  .page__content.d-article > aside.l-gutter {
    grid-column: gutter-start / gutter-end;
    margin: 0.25rem 0 1rem;
    padding: 0 0 0 1rem;
  }
}

/* Side-by-side figure grids */
.page__content.d-article .ak-figure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem;
  align-items: start;
  margin: 2rem 0;
}

.page__content.d-article .ak-figure-grid figure {
  margin: 0;
}

/* Method comparison grids */
.page__content.d-article .ak-method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem 1.75rem;
  margin: 1.75rem 0;
}

.page__content.d-article .ak-method-grid > div {
  padding: 1rem 1.15rem;
  border-top: 1px solid var(--global-divider-color);
  border-bottom: 1px solid var(--global-divider-color);
  background: var(--global-bg-color);
  font-size: 0.94rem;
  font-weight: 300;
  line-height: 1.6;
}

.page__content.d-article .ak-method-grid strong {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

/* Tables — exact reference style (subtle hairline rules, bold normal-case headers) */
.d-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  margin: 1.75rem 0;
  -webkit-overflow-scrolling: touch;
}

.page__content.d-article table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  width: 100%;
  margin: 1.75rem 0;
  border-collapse: collapse;
  border: 0;
  border-top: 1px solid var(--global-divider-color);
  border-bottom: 1px solid var(--global-divider-color);
  font-family: var(--d-font);
  font-size: 0.94rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

.page__content.d-article .d-table-wrap > table {
  display: table;
  margin: 0;
  overflow-x: visible;
}

.page__content.d-article thead {
  background: transparent;
  border-bottom: 1px solid var(--global-divider-color);
}

.page__content.d-article th {
  padding: 0.75rem 1rem 0.75rem 0;
  font-size: 0.94rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--global-text-color);
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--global-divider-color);
  vertical-align: top;
}

.page__content.d-article td {
  padding: 0.75rem 1rem 0.75rem 0;
  font-weight: 300;
  color: var(--global-text-color);
  border: 0;
  border-bottom: 1px solid var(--global-divider-color);
  vertical-align: top;
}

.page__content.d-article tbody tr:last-child td {
  border-bottom: 0;
}

.page__content.d-article th:last-child,
.page__content.d-article td:last-child {
  padding-right: 0;
}

/* Code & details blocks */
.page__content.d-article p > code,
.page__content.d-article li > code,
.page__content.d-article td > code,
.page__content.d-article figcaption > code {
  font-family: var(--d-mono);
  font-size: 0.84em;
  font-weight: 400;
  padding: 2px 5px;
  border: 0;
  border-radius: 3px;
  background: var(--global-code-bg-color);
  color: var(--global-text-color);
}

.page__content.d-article :is(p, li, td, figcaption) > code::before,
.page__content.d-article :is(p, li, td, figcaption) > code::after {
  content: none;
}

.page__content.d-article pre,
.page__content.d-article div.highlighter-rouge {
  margin: 1.5rem 0;
  border-radius: 4px;
  background: #f8f9fa;
  border: 1px solid var(--global-divider-color);
}

.page__content.d-article div.highlighter-rouge pre {
  margin: 0;
  border: 0;
  background: transparent;
}

.page__content.d-article pre {
  padding: 0.9rem 1.15rem;
  overflow-x: auto;
  font-family: var(--d-mono);
  font-size: 0.85rem;
  line-height: 1.55;
}

.page__content.d-article details {
  color: var(--global-text-color);
  background-color: var(--global-code-bg-color);
  padding: 0.65rem 1rem;
  border-radius: 6px;
  margin: 0 0 1.25rem;
  overflow: auto;
  max-width: 100%;
}

.page__content.d-article details summary {
  color: var(--global-theme-color);
  font-weight: 500;
}

/* Display math containment (MathJax v2 & v3) */
.page__content.d-article .MathJax_Display,
.page__content.d-article .MathJax_Preview,
.page__content.d-article .MJXp-display,
.page__content.d-article .MathJax_CHTML,
.page__content.d-article mjx-container[display="true"] {
  display: block;
  margin: 1.5rem 0 !important;
  padding-block: 4px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.page__content.d-article :is(p, li, td, figcaption) .MathJax_Preview {
  display: inline;
  margin: 0 !important;
  padding: 0;
  overflow: visible;
}

/* ==========================================================================
   4. Interactive Distill Citations & Muted Bibliography (matches #828282 ref)
   ========================================================================== */
.page__content.d-article a.d-cite {
  color: var(--global-theme-color);
  border-bottom: none;
  text-decoration: none;
}

.page__content.d-article a.d-cite:hover,
.page__content.d-article a.d-cite:focus-visible {
  color: var(--global-hover-color);
  text-decoration: underline;
}

.d-cite-hovercard {
  position: fixed;
  z-index: 80;
  max-width: min(400px, calc(100vw - 24px));
  padding: 12px 15px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 4px;
  background: #ffffff;
  color: #000000;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
  font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 0.8125rem;
  font-weight: 300;
  line-height: 1.55;
}

.d-cite-hovercard__eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #828282;
}

.d-cite-hovercard__jump {
  color: #2698ba;
  text-decoration: none;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.75rem;
}

.d-cite-hovercard__jump:hover {
  text-decoration: underline;
}

.d-cite-hovercard__body {
  margin: 0;
  color: #000000;
}

.d-cite-hovercard__body strong {
  font-weight: 600;
  color: #000000;
}

.d-cite-hovercard__body a {
  color: #2698ba;
  text-decoration: none;
}

.d-cite-hovercard__body a:hover {
  text-decoration: underline;
}

/* References section styled like Distill d-appendix bibliography (#828282) */
.page__content.d-article .d-references-heading {
  margin-top: 3rem;
  padding-top: 1.75rem;
  padding-bottom: 0;
  border-top: 1px solid var(--global-divider-color);
  border-bottom: 0;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--global-distill-app-color);
}

.page__content.d-article .d-references-list {
  list-style: none;
  padding-left: 0;
  counter-reset: d-ref;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.65;
  color: var(--global-distill-app-color);
}

.page__content.d-article .d-references-list > li {
  position: relative;
  padding-left: 2rem;
  margin-bottom: 0.85rem;
  counter-increment: d-ref;
  scroll-margin-top: calc(var(--nav-height) + 28px);
  color: var(--global-distill-app-color);
  font-weight: 400;
  overflow-wrap: anywhere;
}

.page__content.d-article .d-references-list > li::before {
  content: counter(d-ref) ".";
  position: absolute;
  left: 0;
  top: 0;
  font-variant-numeric: tabular-nums;
  color: var(--global-distill-app-color);
}

.page__content.d-article .d-references-list > li strong {
  color: var(--global-distill-app-color);
  font-weight: 600;
}

.page__content.d-article .d-references-list > li a {
  color: var(--global-distill-app-color);
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

.page__content.d-article .d-references-list > li a:hover {
  color: var(--global-hover-color);
  border-bottom-color: var(--global-hover-color);
}

.page__content.d-article .d-references-list > li:target {
  background: var(--global-code-bg-color);
  border-radius: 4px;
  padding-block: 4px;
  padding-right: 8px;
}

/* ==========================================================================
   5. d-appendix — Pure white centered scholarly appendix (matches ref-bottom)
   ========================================================================== */
.d-appendix {
  background: var(--global-bg-color);
  border-top: 1px solid var(--global-divider-color);
  padding: 2.5rem 0 4rem;
  color: var(--global-distill-app-color);
  font-size: 0.85rem;
  line-height: 1.65;
}

.d-citation {
  margin-bottom: 2.5rem;
  min-width: 0;
}

.d-citation h3 {
  margin: 0 0 0.75rem;
  font-family: var(--d-font);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--global-distill-app-color);
}

.d-citation-lead {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  color: var(--global-distill-app-color);
}

.d-citation-short {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--global-distill-app-color);
  overflow-wrap: anywhere;
}

.d-citation-short a {
  color: var(--global-distill-app-color);
  text-decoration: underline;
}

.d-citation-short a:hover {
  color: var(--global-hover-color);
}

.d-bibtex-wrap {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--global-divider-color);
  border-radius: 4px;
  background: var(--global-bg-color);
  overflow: hidden;
}

.d-bibtex-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--global-divider-color);
  background: #fafafa;
}

.d-bibtex-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--global-distill-app-color);
}

.d-copy-bibtex {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  border: 1px solid var(--global-divider-color);
  border-radius: 4px;
  background: var(--global-bg-color);
  color: var(--global-theme-color);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}

.d-copy-bibtex:hover {
  border-color: var(--global-theme-color);
  color: var(--global-hover-color);
}

.d-bibtex {
  margin: 0;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  font-family: var(--d-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--global-distill-app-color);
  overflow-x: auto;
}

.d-bibtex code {
  background: transparent;
  border: 0;
  padding: 0;
  white-space: pre;
}

/* Article footer inside d-appendix */
.d-appendix .ak-article-footer {
  margin-top: 0;
  gap: 28px;
  min-width: 0;
}

.d-appendix .ak-article-footer > * {
  min-width: 0;
}

.d-appendix .ak-article-meta {
  padding-top: 1.5rem;
  border-top: 1px solid var(--global-divider-color);
  color: var(--global-distill-app-color);
  font-size: 0.82rem;
}

.d-appendix .ak-article-meta strong {
  color: var(--global-text-color);
}

.d-appendix .page__taxonomy-item {
  border-color: var(--global-divider-color);
  background: var(--global-bg-color);
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 4px;
  color: var(--global-distill-app-color);
}

.d-appendix .page__taxonomy-item:hover {
  border-color: var(--global-theme-color);
  color: var(--global-theme-color);
}

.d-appendix .page__share-title {
  color: var(--global-distill-app-color);
  font-size: 0.8rem;
}

.d-appendix .page__share .btn {
  color: var(--global-theme-color) !important;
  border-color: var(--global-divider-color) !important;
  background: var(--global-bg-color);
  border-radius: 4px;
}

.d-appendix .page__share .btn:hover {
  border-color: var(--global-theme-color) !important;
}

.d-appendix .ak-post-navigation {
  border-block-color: var(--global-divider-color);
}

.d-appendix .ak-post-navigation span {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--global-distill-app-color);
}

.d-appendix .ak-post-navigation strong {
  color: var(--global-text-color);
  font-weight: 500;
}

.d-appendix .ak-post-navigation a:hover strong {
  color: var(--global-theme-color);
}

.d-appendix .ak-topic-related__title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--global-text-color);
}

.d-appendix .ak-topic-related__desc {
  color: var(--global-text-color);
  font-weight: 300;
}

.d-appendix .ak-topic-related__desc a,
.d-appendix .ak-topic-card__title a {
  color: var(--global-theme-color);
}

.d-appendix .ak-topic-card {
  background: var(--global-bg-color);
  border-color: var(--global-divider-color);
  border-radius: 4px;
}

.d-appendix .ak-topic-card__meta,
.d-appendix .ak-topic-card__excerpt,
.d-appendix .ak-topic-card__tag {
  color: var(--global-distill-app-color);
}

.d-comments {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--global-divider-color);
}

/* Floating Back-to-Top button (matches vanilla-back-to-top in reference) */
.d-back-to-top {
  position: fixed;
  right: 30px;
  bottom: 30px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--global-back-to-top-bg-color);
  color: var(--global-back-to-top-text-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
  transition: background-color 0.18s ease, transform 0.18s ease;
}

.d-back-to-top:hover {
  background: var(--global-theme-color);
  transform: translateY(-2px);
}

/* ==========================================================================
   6. Mobile & Print adjustments
   ========================================================================== */
@media (max-width: 767px) {
  .d-title {
    padding: 2.25rem 0 1.25rem;
  }

  .page__content.d-article {
    padding: 1.75rem 0 2.75rem;
    font-size: 1rem;
  }

  .page__content.d-article .ak-figure-grid,
  .page__content.d-article .ak-method-grid {
    grid-template-columns: 1fr;
  }

  .d-back-to-top {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 480px) {
  .d-byline__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem 1rem;
  }

  .ak-distill-article .d-headline {
    font-size: 30px;
  }

  .page__content.d-article h2 {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .d-reading-progress {
    display: none;
  }

  .d-back-to-top,
  .page__content.d-article .d-heading-anchor {
    transition: none;
  }
}

@media print {
  .d-reading-progress,
  .d-contents,
  .d-copy-bibtex,
  .d-cite-hovercard,
  .d-heading-anchor,
  .d-back-to-top {
    display: none !important;
  }

  .d-title,
  .d-byline,
  .page__content.d-article,
  .d-appendix {
    display: block !important;
  }
}
