/*
 * Clef docs (css/docs.css): /docs, /terms, /privacy and /404. Loaded after css/clef.css and built on its tokens.
 *
 * The docs read like the Cloudflare blog: a quiet side nav with a scrollspy, a 760 px column, cream formula
 * cards with orange uppercase labels, tables in mono with tabular numbers, and a to-scale timing diagram that
 * turns vertical on phones. CSP: no inline styles; dynamic values go through el.style.setProperty.
 */

/* ------------------------------------------------------------------ page head */

.docs-head { border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--alabaster), var(--paper) 85%); }
.docs-head .eyebrow { margin-bottom: 14px; }
.docs-staff { overflow: visible; }
.docs-staff .staff-lines path { stroke: var(--staff-soft, #fde2bd); stroke-width: 1.5; fill: none; }
.docs-staff .staff-spark { fill: var(--spark, #f8a225); }
.docs-staff .staff-spark.is-small { opacity: .75; }

/* ------------------------------------------------------------------ layout */

.docs-layout {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: 0 clamp(32px, 5vw, 72px);
  align-items: start;
  padding-block: clamp(36px, 5vw, 56px) clamp(64px, 8vw, 104px);
}
.doc { min-width: 0; max-width: 780px; }

/* ------------------------------------------------------------------ the side nav (scrollspy) */

.toc { position: sticky; top: calc(var(--hdr-h) + 28px); align-self: start; max-height: calc(100vh - var(--hdr-h) - 56px); overflow: auto; padding-bottom: 8px; scrollbar-width: thin; }
.toc-title { font: 600 11.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px 14px; }
.toc-list { display: grid; gap: 1px; border-left: 1px solid var(--line); }
.toc-list a {
  position: relative; display: block; padding: 6px 10px 6px 14px; margin-left: -1px;
  border-left: 2px solid transparent; font-size: 14px; line-height: 1.35; color: var(--muted);
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.toc-list a:hover { color: var(--ink); }
.toc-list a.is-active { color: var(--ink); font-weight: 600; border-left-color: var(--orange); }
.toc-cta { margin: 22px 0 0 14px; font-size: 14px; }
.toc-toggle { display: none; }

@media (max-width: 960px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); padding-top: 0; }
  .doc { max-width: none; }
  .toc {
    position: sticky; top: var(--hdr-h); z-index: 30; max-height: none; overflow: visible;
    margin-inline: calc(-1 * var(--gutter)); padding: 0 var(--gutter);
    background: rgba(255, 255, 255, .94); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line); margin-bottom: 28px;
  }
  .toc-title, .toc-cta { display: none; }
  .toc-toggle {
    display: flex; align-items: center; gap: 10px; width: 100%; height: 48px; text-align: left;
    font-size: 14px; color: var(--ink);
  }
  .toc-toggle-label { font: 600 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); flex: none; }
  .toc-current { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
  .toc-chev { flex: none; color: var(--muted); transition: transform .25s var(--ease-out); }
  .toc.is-open .toc-chev { transform: rotate(180deg); }
  /* open: a solid drop-down panel under the bar, over a scrim; it never takes flow space, so nothing jumps */
  .toc-list {
    display: none; border-left: 0; position: absolute; left: 0; right: 0; top: 100%;
    padding: 4px var(--gutter) 14px; background: var(--paper); border-bottom: 1px solid var(--line);
    box-shadow: 0 22px 40px rgba(21, 20, 20, .1);
    max-height: calc(100dvh - var(--hdr-h) - 48px - 20px); overflow: auto; overscroll-behavior: contain;
  }
  .js .toc-list { display: none; }
  .toc.is-open { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .toc.is-open .toc-list { display: grid; align-content: start; animation: toc-in .22s var(--ease-out); }
  .toc-scrim { position: fixed; inset: 0; z-index: 29; background: rgba(21, 20, 20, .24); animation: scrim-in .2s var(--ease-out); }
  .toc-list a { border-left: 0; margin: 0; padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
  .toc-list li:last-child a { border-bottom: 0; }
  .toc-list a.is-active { color: var(--orange-text, #c93a00); }
  html:not(.js) .toc-list { display: grid; position: static; box-shadow: none; padding-inline: 0; }
  html:not(.js) .toc-toggle { display: none; }
}
@keyframes toc-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes scrim-in { from { opacity: 0; } }
.toc-scrim[hidden] { display: none; }
@media (min-width: 961px) { .toc-scrim { display: none; } }

/* ------------------------------------------------------------------ prose */

/* html scroll-padding-top already clears the header; these margins only add air (and the phone bar below) */
.doc-sec { padding-block: 8px 44px; scroll-margin-top: 12px; }
.doc-sec + .doc-sec { border-top: 1px solid var(--line); padding-top: 44px; }
@media (max-width: 960px) { .doc-sec, .doc .doc-h3 { scroll-margin-top: 60px; } }

.doc-h2 { position: relative; font: 600 clamp(26px, 3vw, 32px)/1.15 var(--display); letter-spacing: -.022em; color: var(--ink); margin-bottom: 18px; text-wrap: balance; }
.doc-h3 { position: relative; font: 600 19px/1.3 var(--display); letter-spacing: -.012em; color: var(--ink); margin: 34px 0 12px; scroll-margin-top: 12px; }
/* prose rules stay out of mounted widgets (the kit scorer styles itself) */
.doc p:where(:not(.widget-slot *)) { margin: 0 0 16px; font-size: 16.5px; line-height: 1.72; color: var(--body); text-wrap: pretty; }
.doc p:where(:not(.widget-slot *)) b, .doc li:where(:not(.widget-slot *)) b { color: var(--ink); font-weight: 600; }
.doc var:where(:not(.widget-slot *)) { font-family: var(--math); font-style: italic; font-size: 1.06em; color: var(--ink); }
.doc sub:where(:not(.widget-slot *)), .doc sup:where(:not(.widget-slot *)) { line-height: 0; }
.doc .note { font-size: 14.5px; line-height: 1.65; color: var(--muted); }
.doc .break { word-break: break-all; }
.doc .mono { overflow-wrap: anywhere; }
.doc .nowrap { white-space: nowrap; }
.doc code.code-wrap { white-space: normal; overflow-wrap: anywhere; line-height: 1.9; }

/* anchor links on headings (added by js/docs.js) */
.anchor {
  position: absolute; left: -26px; top: 50%; transform: translateY(-50%);
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: var(--r-xs);
  color: var(--faint); opacity: 0; transition: opacity .2s var(--ease), color .2s var(--ease);
}
.doc-h2:hover .anchor, .doc-h3:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--orange); }
@media (max-width: 1100px) { .anchor { left: auto; right: -2px; position: relative; display: inline-grid; transform: none; top: 2px; margin-left: 6px; opacity: .55; } }

/* key facts: a quiet two-column list, no boxes */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; margin: 26px 0 24px; border-top: 1px solid var(--line); }
.facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.facts dt { font: 600 11.5px/1.3 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--orange-text, #c93a00); flex: none; }
.facts dd { margin: 0; font-size: 14.5px; color: var(--ink); text-align: right; }
@media (max-width: 600px) { .facts { grid-template-columns: minmax(0, 1fr); } }

/* steps with orange numerals */
.steps { counter-reset: step; display: grid; gap: 14px; margin: 26px 0 8px; }
.steps li { counter-increment: step; position: relative; padding-left: 44px; font-size: 16px; line-height: 1.68; color: var(--body); }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 1px;
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--cream); border: 1.5px solid var(--amber); color: var(--orange-text, #c93a00);
  font: 600 13px/1 var(--mono);
}

/* bullet lists: a short orange stroke */
.ticks { display: grid; gap: 12px; margin: 18px 0 20px; }
.ticks li { position: relative; padding-left: 26px; font-size: 16px; line-height: 1.68; color: var(--body); }
.ticks li::before { content: ''; position: absolute; left: 5px; top: .62em; width: 6px; height: 6px; border-radius: 1.5px; background: var(--orange); transform: rotate(45deg); }
.ticks.is-risk li::before { background: var(--carrot); }

/* ------------------------------------------------------------------ the live strip */

.live-strip { display: inline-flex; align-items: center; gap: 10px; margin: 6px 0 10px !important; padding: 8px 14px; border-radius: 999px; background: var(--cream); border: 1px solid var(--amber-soft); font: 500 13.5px/1.3 var(--mono) !important; color: var(--rust) !important; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 3px rgba(255, 94, 31, .16); animation: pulse 1.6s var(--ease) infinite; flex: none; }

/* ------------------------------------------------------------------ the timing diagram */

.timeline { margin: 18px 0 8px; padding: 22px 20px 14px; border-radius: var(--r-md); background: var(--alabaster); border: 1px solid var(--line); }
.tl { width: 100%; height: auto; overflow: visible; }
.tl-tall { display: none; max-width: 340px; margin-inline: auto; }
@media (max-width: 640px) {
  .timeline { padding: 18px 12px 12px; }
  .tl-wide { display: none; }
  .tl-tall { display: block; }
}
.tl text { font-family: var(--sans); }
.tl-open { fill: var(--cream); stroke: var(--amber); stroke-width: 1.5; }
.tl-hour { fill: var(--cream-2); stroke: #ef7645; stroke-width: 1.5; }
.tl-twap { fill: var(--orange); }
.tl-open-next { fill: var(--paper); stroke: var(--amber-soft); stroke-width: 1.5; stroke-dasharray: 5 5; }
.tl-twap-next { fill: #ffc9b0; }
.tl-hour-next { fill: var(--paper); stroke: var(--amber-soft); stroke-width: 1.5; stroke-dasharray: 5 5; }
.tl-label { font-size: 16px; font-weight: 600; fill: var(--rust); }
.tl-label-next { font-size: 14.5px; font-weight: 500; fill: var(--muted); }
.tl-callout { font: 600 13.5px/1 var(--mono); letter-spacing: .06em; fill: var(--orange-text, #c93a00); }
.tl-callout-sub { font: 500 13.5px/1 var(--mono); fill: var(--muted); }
.tl-leader { stroke: var(--orange-2); stroke-width: 1.2; stroke-dasharray: 2 3; fill: none; }
.tl-flag { stroke: var(--ink); stroke-width: 1.5; fill: none; }
.tl-flag-head { fill: var(--ink); }
.tl-axis-line { stroke: var(--line-2); stroke-width: 1.5; fill: none; }
.tl-tick { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.tl-time { font: 600 14px/1 var(--mono); fill: var(--ink); }
.tl-event { font: 500 13.5px/1 var(--mono); fill: var(--muted); }
.tl-note { font-size: 13px; fill: var(--muted); }
.tl-note-b { font-size: 14px; font-weight: 600; fill: var(--ink); }
.tl-cap { margin-top: 12px; font-size: 13.5px; line-height: 1.55; color: var(--muted); }

/* ------------------------------------------------------------------ tables */

.doc .tbl-wrap { margin: 18px 0 20px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); }
.doc-tbl { font-size: 14.5px; }
.doc-tbl th, .doc-tbl td { padding: 11px 14px; }
.doc-tbl thead th { padding-top: 13px; background: var(--alabaster); }
.doc-tbl tbody th { font: 500 14.5px/1.4 var(--sans); letter-spacing: -.005em; text-transform: none; text-align: left; color: var(--ink); border-bottom: 1px solid var(--line); white-space: nowrap; }
.doc-tbl tbody th code { font-size: .86em; }
.doc-tbl td.num, .doc-tbl th.num { white-space: nowrap; }
.doc-tbl tr:last-child th { border-bottom: 0; }
.q-tbl td { vertical-align: top; line-height: 1.55; }
.q-tbl td:nth-child(3) { min-width: 240px; }
.q-tbl td:last-child { color: var(--body); min-width: 180px; }

.kind { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--chip); color: var(--rust); font: 600 11.5px/1 var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.asset { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); white-space: nowrap; margin-right: 6px; vertical-align: middle; }
.asset .logo { --logo-size: 18px; }
.asset-row { display: flex; flex-wrap: wrap; gap: 4px 4px; margin-bottom: 6px; }

/* the worked example */
.ex-tbl .ex-q th { padding-top: 16px; background: var(--paper); font-weight: 500; color: var(--ink); white-space: normal; }
.ex-tbl .ex-q th .muted { font-size: 14px; margin-left: 6px; }
.ex-tbl tr.is-hit th, .ex-tbl tr.is-hit td { background: var(--cream-2); }
.ex-tbl tr.is-hit th { box-shadow: inset 3px 0 0 var(--orange); color: var(--orange-text, #c93a00); font-weight: 600; }
.ex-tbl tr.is-hit td { color: var(--ink); font-weight: 600; }
.ex-tbl .ex-sum th, .ex-tbl .ex-sum td { background: var(--alabaster); font-weight: 600; color: var(--ink); border-top: 1px solid var(--line-2); }
.ex-tbl .ex-sum th { white-space: normal; }
.ex-tbl .ex-stake td { color: var(--ink); }
.ex-tbl .ex-eth td { color: var(--orange-text, #c93a00); font-weight: 600; }
.ex-tbl td.up { color: var(--good); }
.ex-tbl td.down { color: var(--bad); }
.ex-pay { font-size: 13.5px; }
@media (max-width: 640px) { .doc-tbl { font-size: 13px; } .doc-tbl th, .doc-tbl td { padding: 10px 11px; } .ex-pay { font-size: 12.5px; } }

.moves { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 20px; margin: 14px 0 18px; }
.moves li { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.moves .asset { grid-row: 1 / 3; align-self: center; }
.moves .mono { text-align: right; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.moves .muted { text-align: right; font: 500 12px/1.3 var(--mono); }

.pack-tbl td:nth-child(2) { white-space: nowrap; }

/* the re-check badge */
.verify { display: inline-flex; align-items: center; gap: 10px; padding: 7px 14px 7px 12px; border-radius: 999px; background: var(--concrete); font: 500 13px/1.35 var(--mono) !important; color: var(--muted) !important; }
.verify-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.verify.is-ok { background: #e9f6ee; color: var(--good) !important; }
.verify.is-ok .verify-dot { background: var(--good); }
.verify.is-bad { background: #fdecea; color: var(--bad) !important; }
.verify.is-bad .verify-dot { background: var(--bad); }
td.is-diff { box-shadow: inset 0 -2px 0 var(--bad); }

/* ------------------------------------------------------------------ formula cards */

.eq-card { margin: 20px 0; padding: 18px 22px 16px; background: var(--cream); border: 1.5px solid var(--amber); border-radius: var(--r-md); }
.eq-card.is-hot { background: var(--cream-2); border-color: #ef7645; }
.eq-label { margin: 0 0 6px !important; font: 600 12px/1.2 var(--sans) !important; letter-spacing: .07em; text-transform: uppercase; color: var(--orange-text, #c93a00) !important; }
.eq-card .mathbox { padding: 6px 0 8px; }
.eq-card math[display='block'] { font-size: 1.26em; }
.doc math.eq-sub { font-size: 1.08em !important; margin-top: 4px; }
.doc math.eq-cont { margin-top: 2px; }
@media (max-width: 520px) {
  .eq-card { padding: 16px 16px 14px; }
  .eq-card math[display='block'] { font-size: 1.06em; }
  .eq-plain math[display='block'] { font-size: 1em; }
  .eq-plain { padding: 12px 12px; }
}
.eq-say { margin: 4px 0 0 !important; font-size: 15px !important; line-height: 1.65 !important; color: var(--rust) !important; }
.eq-say math { font-size: 1.04em; }
.eq-plain { margin: 6px 0 18px; padding: 14px 18px; border-left: 2px solid var(--amber); background: var(--alabaster); border-radius: 0 var(--r) var(--r) 0; }
.doc math:where(:not(.widget-slot *)) { color: var(--ink); }
.doc .mathbox { scrollbar-width: thin; }
.doc .mathbox.eq-row { display: flex; flex-wrap: wrap; align-items: center; column-gap: 1.8em; row-gap: 10px; }
.doc .mathbox.eq-row > math { flex: 0 0 auto; }
.doc .mathbox > math[display='block'] { overflow: visible; }
.doc .mathbox math.eq-aside { color: var(--rust); }

/* sideways scrollers (tables, code, formulas): js/docs.js wraps each in .sx and fades the edge that hides more */
.sx { position: relative; }
.sx::before, .sx::after {
  content: ''; position: absolute; top: 1px; bottom: 1px; width: 36px; z-index: 3; pointer-events: none;
  opacity: 0; transition: opacity .2s var(--ease);
}
.sx::before { left: 1px; background: linear-gradient(90deg, var(--sx-bg, #fff) 15%, transparent); border-radius: var(--sx-r, 0) 0 0 var(--sx-r, 0); }
.sx::after {
  right: 1px; border-radius: 0 var(--sx-r, 0) var(--sx-r, 0) 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='10.25' fill='%23ffffff' stroke='%23fbb34f' stroke-width='1.5'/%3E%3Cpath d='M9.5 7 13.5 11 9.5 15' fill='none' stroke='%23d63c01' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 5px top var(--sx-arrow-y, 50%) / 22px 22px,
    linear-gradient(270deg, var(--sx-bg, #fff) 35%, transparent);
}
.sx.is-l::before, .sx.is-r::after { opacity: 1; }
.sx.sx-tbl::before { display: none; } /* tables keep their label column in view instead */
.sx.sx-tbl { margin: 18px 0 20px; }
.doc .sx > .tbl-wrap { margin: 0; }
.sx.sx-pre::before, .sx.sx-pre::after { top: 0; bottom: 0; }
/* phones: the request's long state line reads as a paragraph instead of a 4,000 px line */
@media (max-width: 720px) { .doc pre[data-request] { white-space: pre-wrap; overflow-wrap: anywhere; } }
@media (max-width: 400px) { .doc .eq-plain math[display='block'] { font-size: .94em; } }

/* the scorer widget slot (js/ui/scorer.js, when present). The doc column is narrower than the scorer's own
   two-column breakpoint (880 px of viewport), so in the docs it always reads as one column. */
.widget-slot { margin: 26px 0 6px; }
.doc .widget-slot .sc { grid-template-columns: minmax(0, 1fr); }

/* ------------------------------------------------------------------ assets */

.assets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 22px 0 10px; }
.asset-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); font-size: 13.5px; color: var(--muted); min-width: 0; }
.asset-chip .logo { --logo-size: 22px; }
.asset-chip b { color: var(--ink); font: 600 13.5px/1 var(--mono); }
.asset-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ code */

.doc .code { margin: 16px 0 22px; }
.doc .code pre { max-height: 520px; }
.doc .code-title b { font-weight: 600; }

/* ------------------------------------------------------------------ FAQ */

.faq { border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 2px;
  font: 600 16.5px/1.4 var(--display); letter-spacing: -.01em; color: var(--ink); cursor: pointer; list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ''; flex: none; width: 10px; height: 10px; margin-right: 6px;
  border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted);
  transform: rotate(45deg) translateY(-3px); transition: transform .25s var(--ease-out);
}
.faq details[open] summary::after { transform: rotate(225deg) translateY(-3px); }
.faq summary:hover { color: var(--orange-text, #c93a00); }
.faq details p { padding: 0 2px 18px; margin: 0; }

/* ------------------------------------------------------------------ the end */

.doc-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px 28px; margin-top: 12px; padding: 32px 0 0; border-top: 1px solid var(--line); }
.doc-end-line { margin: 0 !important; font: 500 clamp(22px, 2.6vw, 28px)/1.2 var(--display) !important; letter-spacing: -.02em; color: var(--ink) !important; }

/* =================================================================== legal pages and 404 */

.legal { padding-block: clamp(36px, 5vw, 56px) clamp(64px, 8vw, 104px); }
.legal .doc { margin-inline: auto; max-width: 720px; }
.legal-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 28px !important; font: 500 13px/1.4 var(--mono) !important; color: var(--muted) !important; }
.legal .doc-h2 { font-size: 22px; margin: 34px 0 10px; }
.legal .doc-h2:first-of-type { margin-top: 8px; }
.legal .doc ul.ticks { margin-top: 8px; }

.nf { position: relative; flex: 1 0 auto; display: grid; place-items: center; overflow: clip; padding-block: clamp(56px, 10vw, 120px); }
.nf-staff { position: absolute; inset: 50% 0 auto; transform: translateY(-50%); width: 100%; height: 220px; pointer-events: none; }
.nf .staff-lines path { stroke: var(--staff-soft, #fde2bd); stroke-width: 1.5; fill: none; }
.nf .nf-note { fill: var(--orange); }
.nf .nf-note-soft { fill: var(--amber-soft); }
.nf .nf-stem { stroke: var(--orange); stroke-width: 3; stroke-linecap: round; }
.nf .nf-stem.is-soft { stroke: var(--amber-soft); }
.nf .nf-spark { fill: var(--spark, #f8a225); }
.nf .nf-float { animation: nf-float 2.8s var(--ease) infinite alternate; }
@keyframes nf-float { from { transform: translateY(2px); } to { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .nf .nf-float { animation: none; } }
.nf-in {
  position: relative; text-align: center; display: grid; justify-items: center; gap: 16px; padding: 40px 72px;
  background: radial-gradient(closest-side, #fff 0%, #fff 72%, rgba(255, 255, 255, 0) 100%);
}
.nf-mini { display: none; width: min(300px, 80vw); height: auto; overflow: visible; margin-bottom: 4px; }
@media (max-width: 720px) {
  .nf { place-items: start center; }
  .nf-staff { display: none; }
  .nf-mini { display: block; }
  .nf-in { padding: 8px 4px; background: none; }
}
.nf-code { font: 600 13px/1 var(--mono); letter-spacing: .14em; color: var(--orange-text, #c93a00); }
.nf-title { font: 600 clamp(32px, 5vw, 52px)/1.06 var(--display); letter-spacing: -.03em; color: var(--ink); text-wrap: balance; max-width: 640px; }
.nf-lede { max-width: 460px; font-size: 17px; line-height: 1.6; color: var(--body); }
.nf-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 6px; }

/* the tall timeline keeps the smaller sizes it was drawn for */
.tl-tall .tl-time { font-size: 12.5px; }
.tl-tall .tl-callout { font-size: 12px; }

/* phones: the questions table stacks; the example tables keep their label column in view while they scroll */
@media (max-width: 640px) {
  .q-tbl thead { display: none; }
  .q-tbl, .q-tbl tbody, .q-tbl tr, .q-tbl td { display: block; width: 100%; }
  .q-tbl tr { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; padding: 14px 14px; border-bottom: 1px solid var(--line); }
  .q-tbl tr:last-child { border-bottom: 0; }
  .q-tbl td { padding: 0; border: 0; min-width: 0 !important; }
  .q-tbl td:nth-child(1) { grid-column: 1; }
  .q-tbl td:nth-child(2) { grid-column: 2; }
  .q-tbl td:nth-child(3), .q-tbl td:nth-child(4) { grid-column: 1 / -1; }
  .q-tbl td:nth-child(4) { font-size: 13.5px; color: var(--muted); }
  .ex-tbl tbody th, .ex-tbl thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--paper); box-shadow: 1px 0 0 var(--line); white-space: normal; min-width: 112px; max-width: 150px; }
  .ex-tbl thead th:first-child { background: var(--alabaster); }
  .ex-tbl tr.is-hit th { background: var(--cream-2); box-shadow: inset 3px 0 0 var(--orange), 1px 0 0 var(--line); }
  .ex-tbl .ex-sum th { background: var(--alabaster); }
}

/* the worked example: the chain's answer column, and score cells with their integer loss beneath */
.ex-tbl td.ex-ans { color: var(--muted); background: var(--alabaster); box-shadow: inset 1px 0 0 var(--line); }
.ex-tbl tr.is-hit td.ex-ans { color: var(--orange-text, #c93a00); background: var(--cream-2); }
.ex-tbl .ex-s { display: block; color: var(--ink); }
.ex-tbl .ex-l { display: block; margin-top: 3px; font: 500 11.5px/1.3 var(--mono); color: var(--muted); }

/* phones: tap targets of at least 44 px, no hover-only anchors */
@media (max-width: 960px) {
  .anchor { display: none; }
  .toc-list a { padding-block: 12px; }
}
@media (max-width: 720px) {
  .doc .code-head { height: 48px; }
  .doc .copy-btn { height: 44px; padding: 0 12px; }
  .doc-end .btn, .nf-actions .btn { --btn-h: 48px; }
  .faq summary { min-height: 56px; }
}

/* ------------------------------------------------------------------ the week (session schedule) */

.week { margin: 18px 0 18px; }
.week-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week-days li { display: grid; gap: 7px; justify-items: start; align-content: start; min-width: 0; }
.week-bar { display: block; width: 100%; height: 10px; border-radius: 3px; background: var(--sand); }
.week-days .is-on .week-bar { background: var(--orange); }
.week-days .is-part .week-bar { background: linear-gradient(90deg, var(--sand) 0 calc(100% / 12), var(--orange) calc(100% / 12)); }
.week-days b { font: 600 13px/1 var(--mono); color: var(--ink); }
.week-sub { font: 500 11.5px/1.3 var(--mono); color: var(--muted); }
.week-cap { display: grid; gap: 4px; margin-top: 12px; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.week-item { display: flex; align-items: flex-start; }
.week-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 7px; vertical-align: -1px; }
.week-key.is-on { background: var(--orange); }
.week-key { flex: none; margin-top: .42em; }
.week-key.is-off { background: var(--sand); }
@media (max-width: 600px) { .week-sub { display: none; } .week-days { gap: 4px; } }

/* phones on their side: the viewport is too short for a second sticky bar under the header, so the
   "On this page" control stays at the top of the article (it still opens in place) */
@media (max-width: 960px) and (max-height: 500px) {
  .toc { position: relative; top: auto; }
  .toc-list { max-height: min(70vh, 320px); }
  .doc-sec, .doc .doc-h3 { scroll-margin-top: 12px; }
}

/* ------------------------------------------------------------------ embed the live round (js/docs.js initEmbed) */

.embed-opts { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 16px; }
.embed-stage { margin: 18px 0 8px; padding: clamp(16px, 3vw, 28px); border-radius: var(--r-md); background: var(--concrete); border: 1px solid var(--line); display: grid; justify-items: center; gap: 12px; transition: background-color .3s var(--ease); }
.embed-stage.is-dark { background: #0c0b0a; border-color: #0c0b0a; }
.embed-frame { display: block; width: 100%; max-width: 460px; height: var(--embed-h, 640px); border: 0; border-radius: var(--r-md); background: transparent; transition: height .25s var(--ease); }
.embed-stage.is-compact .embed-frame { max-width: 420px; }
.doc .embed-cap { font-size: 12.5px; color: var(--muted); }
.embed-stage.is-dark .embed-cap { color: #a39b93; }
@media (max-width: 560px) { .embed-stage { margin-inline: calc(-1 * var(--gutter) / 2); padding: 12px; } }
/* the narrowest phones: a long inline signature in running text may wrap instead of pushing the page sideways */
@media (max-width: 380px) { .doc p > code, .doc li > code { white-space: normal; overflow-wrap: anywhere; } }
