···9191 if (!sup) return;
92929393 // On mobile/tablet, show popover
9494- let isDesktop = window.matchMedia("(min-width: 1024px)").matches;
9494+ let isDesktop = window.matchMedia("(min-width: 1280px)").matches;
9595 if (!isDesktop) {
9696 let store = useFootnotePopoverStore.getState();
9797 if (store.activeFootnoteID === footnoteID) {
+14-2
components/Footnotes/FootnotePopover.tsx
···11"use client";
2233-import { useEffect, useRef, useState, useCallback } from "react";
33+import { useEffect, useRef, useState, useCallback, useMemo } from "react";
44import { create } from "zustand";
55import { useFootnoteContext } from "./FootnoteContext";
66import { FootnoteEditor } from "./FootnoteEditor";
···3232 let [position, setPosition] = useState<{ top: number; left: number; arrowLeft: number } | null>(null);
33333434 let footnote = footnotes.find((fn) => fn.footnoteEntityID === activeFootnoteID);
3535+3636+ // Compute the displayed index from DOM order (matching CSS counters)
3737+ // rather than the data model order, which may differ if footnotes
3838+ // were inserted out of order within a block.
3939+ let displayIndex = useMemo(() => {
4040+ if (!anchorElement || !footnote) return footnote?.index ?? 0;
4141+ let container = anchorElement.closest('.postPageContent');
4242+ if (!container) return footnote.index;
4343+ let allRefs = Array.from(container.querySelectorAll('.footnote-ref'));
4444+ let pos = allRefs.indexOf(anchorElement);
4545+ return pos >= 0 ? pos + 1 : footnote.index;
4646+ }, [anchorElement, footnote]);
35473648 let updatePosition = useCallback(() => {
3749 if (!anchorElement || !popoverRef.current) return;
···110122 >
111123 <FootnoteEditor
112124 footnoteEntityID={footnote.footnoteEntityID}
113113- index={footnote.index}
125125+ index={displayIndex}
114126 editable={permissions.write}
115127 onDelete={
116128 permissions.write