/* Compact table of contents (.toc-*). Uses theme tokens only: --ink, --surface, --stone, --cobalt, --font-sans, --r, --t. */
.toc-c { display: block; margin: 16px 0 0; }
.toc-c[hidden] { display: none; }
.toc-slot { padding-top: 24px; }
.toc-slot > .toc-c { margin: 0; }

/* pill (button and the <details> no-JS fallback share the same box, so swapping causes no layout shift) */
.toc-pill,
.toc-details > summary {
  display: inline-flex; align-items: center; gap: 6px; box-sizing: border-box;
  height: 34px; padding: 0 12px 0 14px; margin: 0;
  font: 600 14px/1 var(--font-sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--stone); border-radius: 999px;
  cursor: pointer; white-space: nowrap; width: auto; max-width: 100%;
  transition: border-color var(--t), color var(--t), box-shadow var(--t);
  -webkit-tap-highlight-color: transparent;
}
.toc-details > summary { list-style: none; }
.toc-details > summary::-webkit-details-marker { display: none; }
.toc-pill:hover, .toc-details > summary:hover { border-color: var(--cobalt); color: var(--cobalt); }
.toc-pill:focus-visible, .toc-details > summary:focus-visible, .toc-fab:focus-visible, .toc-link:focus-visible, .toc-close:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.toc-count { font-variant-numeric: tabular-nums lining-nums; color: inherit; opacity: .7; }
.toc-chev { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--t); }
.toc-pill[aria-expanded="true"] .toc-chev, .toc-details[open] > summary .toc-chev { transform: rotate(180deg); }

/* list (shared) */
.toc-list { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc-list li { margin: 0; padding: 0; }
.toc-link {
  display: block; padding: 8px 12px; border-radius: var(--r);
  font: 400 15px/1.35 var(--font-sans); color: var(--ink); text-decoration: none;
  border-left: 2px solid transparent; transition: background-color var(--t), color var(--t), border-color var(--t);
}
.toc-link:hover { background: color-mix(in srgb, var(--cobalt) 7%, var(--surface)); color: var(--ink); text-decoration: none; }
.toc-link.is-active { color: var(--cobalt); font-weight: 600; border-left-color: var(--cobalt); background: color-mix(in srgb, var(--cobalt) 6%, var(--surface)); }

/* no-JS fallback panel */
.toc-details > nav { margin-top: 8px; max-width: 360px; padding: 6px; background: var(--surface); border: 1px solid var(--stone); border-radius: calc(var(--r) * 2); }

/* desktop dropdown (rendered in <body>, positioned under the pill, overlays content) */
.toc-panel {
  position: absolute; z-index: 70; box-sizing: border-box;
  width: max-content; min-width: 260px; max-width: min(360px, calc(100vw - 32px)); max-height: min(70vh, 520px); overflow: auto;
  padding: 6px; background: var(--surface); border: 1px solid var(--stone); border-radius: calc(var(--r) * 2);
  box-shadow: 0 12px 32px rgba(20, 27, 45, .14);
  opacity: 0; transform: translateY(-4px); transition: opacity var(--t), transform var(--t); pointer-events: none;
}
.toc-panel.is-open { opacity: 1; transform: none; pointer-events: auto; }
.toc-panel[hidden], .toc-sheet[hidden], .toc-scrim[hidden] { display: none; }
.toc-head { display: none; }

/* mobile bottom sheet */
.toc-scrim { position: fixed; inset: 0; z-index: 90; background: rgba(20, 27, 45, .45); opacity: 0; transition: opacity var(--t); }
.toc-scrim.is-open { opacity: 1; }
.toc-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 91; box-sizing: border-box;
  max-height: 75vh; overflow: auto; padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: calc(var(--r) * 3) calc(var(--r) * 3) 0 0; box-shadow: 0 -8px 32px rgba(20, 27, 45, .2);
  transform: translateY(100%); transition: transform 200ms ease;
}
.toc-sheet.is-open { transform: none; }
.toc-sheet .toc-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 8px 12px; border-bottom: 1px solid var(--stone); margin-bottom: 6px; }
.toc-sheet .toc-title { margin: 0; font: 600 14px/1.2 var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink); }
.toc-close { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer; }
.toc-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toc-sheet .toc-link { padding: 11px 12px; font-size: 16px; }

/* mobile sticky pill */
.toc-fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 80;
  box-shadow: 0 6px 20px rgba(20, 27, 45, .18);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity var(--t), transform var(--t);
}
.toc-fab.is-visible { opacity: 1; transform: none; pointer-events: auto; }

@media (min-width: 640px) { .toc-fab { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .toc-panel, .toc-sheet, .toc-scrim, .toc-fab, .toc-chev { transition: none; }
}
html.toc-lock { overflow: hidden; }
