/* ===========================================================================
   /reference/ — the reference library (step 1: the CMS calculator's pages; step 2: the whole-library graph).
   Everything binds to the SITE's custom properties, so the default, light and slate themes are all
   served by one set of rules. State is carried by border style and a glyph, never by colour alone,
   so it survives a monochrome print and a colour-blind reader.
   =========================================================================== */
.rf-wrap { max-width: 1220px; }
.rf-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 1.2rem; padding: 0; font-size: 0.82rem; color: var(--text-muted); }
.rf-crumbs li + li::before { content: '/'; margin-right: 0.35rem; color: var(--text-muted); }
.rf-crumbs a { color: var(--text-muted); text-decoration: none; border-bottom: 1px solid var(--border); }
.rf-crumbs a:hover, .rf-crumbs a:focus-visible { color: var(--text-primary); }

/* --- masthead ------------------------------------------------------------ */
.rf-mast { padding-bottom: 1.4rem; border-bottom: 1px solid var(--border); margin-bottom: 1.6rem; }
.rf-eyebrow { font-size: 0.76rem; font-weight: 600; letter-spacing: 0.09em; color: var(--accent-text); margin: 0 0 0.7rem; text-transform: uppercase; }
.rf-mast h1 { font-size: clamp(1.6rem, 3.6vw, 2.3rem); line-height: 1.15; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
.rf-mast h1 + .rf-lede { margin-top: 0.7rem; }
.rf-mast__row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; }
.rf-id { margin: 0.4rem 0 0.9rem; font-size: 0.78rem; color: var(--text-muted); }
.rf-id code, .rf-caption code, .rf-formula code, .rf-prose code { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.rf-lede { max-width: 72ch; color: var(--text-primary); font-size: 1.04rem; margin: 0 0 0.8rem; }
.rf-lede p { margin: 0 0 0.6rem; }
.rf-prose p { max-width: 72ch; color: var(--text-muted); margin: 0 0 0.7rem; }
.rf-meta { font-size: 0.86rem; margin: 0.6rem 0 0; }

/* --- the state chip: border and glyph, not colour ------------------------- */
.rf-chip { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.78rem; font-weight: 500; padding: 0.22rem 0.6rem;
  border: 1px solid var(--text-muted); border-radius: 2px; background: var(--bg-surface); color: var(--text-primary); }
.rf-chip__mark { width: 0.6rem; height: 0.6rem; border: 1px solid currentColor; box-sizing: border-box; }
.rf-chip--published .rf-chip__mark { background: currentColor; }
.rf-chip--estimated { border-style: dashed; }
.rf-chip--estimated .rf-chip__mark { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.rf-chip--choice { border-style: double; border-width: 3px; }
.rf-chip--choice .rf-chip__mark { border-radius: 50%; }
.rf-chip--absent { border-style: dotted; }

/* --- two columns ---------------------------------------------------------- */
.rf-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.4rem; }
@media (min-width: 1040px) { .rf-cols { grid-template-columns: minmax(0, 1fr) 340px; gap: 2rem; align-items: start; } }
.rf-main { display: flex; flex-direction: column; gap: 1.2rem; min-width: 0; }
.rf-aside { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

/* --- cards ---------------------------------------------------------------- */
.rf-card, .rf-side, .rf-verify { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; min-width: 0; }
.rf-card__h, .rf-side__h { font-size: 0.95rem; margin: 0 0 0.8rem; letter-spacing: -0.005em; }
.rf-side__h { font-size: 0.86rem; }
.rf-card h3 { font-size: 0.92rem; margin: 1.2rem 0 0.5rem; }
.rf-card p { margin: 0 0 0.6rem; max-width: 72ch; }
.rf-card--warm { border-color: var(--accent-warm); }
.rf-verify { border-left: 3px solid var(--accent-warm); }
.rf-verify p { margin: 0 0 0.3rem; max-width: 72ch; }
.rf-mute { color: var(--text-muted); }
.rf-caption { font-size: 0.8rem; color: var(--text-muted); margin: 0.6rem 0 0; }
/* screen-reader text: kept at the top left of its own scroll box, so a table scrolling sideways on a
   phone does not drag it — and the page — past the right edge */
.rf-sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.rf-kv { margin: 0; }
.rf-kv > div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0.8rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.rf-kv > div:last-child { border-bottom: 0; }
.rf-kv dt { color: var(--text-muted); }
.rf-kv dd { margin: 0; overflow-wrap: anywhere; }
.rf-kv--tight > div { grid-template-columns: 6.2rem minmax(0, 1fr); font-size: 0.82rem; padding: 0.35rem 0; }
@media (max-width: 560px) { .rf-kv > div { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; } }
.rf-card__foot { margin: 0.8rem 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; font-size: 0.84rem; }
.rf-btn { display: inline-block; border: 1px solid var(--border); border-radius: 2px; padding: 0.42rem 0.75rem; background: var(--bg-elevated); color: var(--text-primary); text-decoration: none; }
.rf-btn:hover, .rf-btn:focus-visible { border-color: var(--accent); }

/* --- extracts, quoted ----------------------------------------------------- */
.rf-extract { margin: 0 0 1rem; }
.rf-extract img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); background: #fff; }
.rf-extract figcaption { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.5rem; max-width: 72ch; }
.rf-quote { margin: 0 0 0.8rem; padding: 0.6rem 0.9rem; border-left: 3px solid var(--border); background: var(--bg-elevated); }
.rf-quote p { margin: 0; font-style: italic; }
.rf-quote footer { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.35rem; }

/* --- tables --------------------------------------------------------------- */
.rf-scroll { position: relative; overflow-x: auto; max-width: 100%; }
.rf-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.rf-table th, .rf-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.rf-table thead th { font-weight: 600; font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.rf-table .rf-n { text-align: right; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.82rem; white-space: nowrap; }
.rf-table .rf-dash { color: var(--text-muted); }
.rf-unit { font-weight: 400; color: var(--text-muted); }
.rf-table .rf-st { width: 1.6rem; text-align: center; }
.rf-mark { cursor: help; color: var(--warn-text); }
.rf-row--absent td { color: var(--text-muted); }
.rf-table--kv th { width: 46%; font-weight: 500; color: var(--text-muted); font-size: 0.84rem; }
.rf-table--kv td { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.82rem; }
/* on a phone a table keeps its rows one line high and scrolls in its own box, rather than stacking a
   word per line down a narrow column */
@media (max-width: 700px) { .rf-table:not(.rf-table--kv) td, .rf-table:not(.rf-table--kv) th { white-space: nowrap; } }
.rf-group { border: 1px solid var(--border); border-radius: 2px; margin: 0 0 0.5rem; }
.rf-group > summary { cursor: pointer; padding: 0.5rem 0.7rem; font-weight: 500; font-size: 0.88rem; }
.rf-group > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rf-group[open] > summary { border-bottom: 1px solid var(--border); }
.rf-held { display: flex; gap: 0.7rem; align-items: flex-start; margin: 0; padding: 0.7rem 0.8rem; border: 1px dashed var(--text-muted); border-radius: 2px; }
.rf-held p { margin: 0; }
.rf-caption + .rf-held { margin-top: 0.7rem; }
.rf-held__mark { flex: 0 0 auto; width: 1.2rem; height: 1.2rem; margin-top: 0.15rem; border: 1px dotted var(--text-muted);
  background: repeating-linear-gradient(45deg, transparent 0 3px, var(--border) 3px 5px); }
.rf-formula { margin: 0 0 0.8rem; padding: 0.6rem 0.8rem; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 2px; overflow-x: auto; }
.rf-units { margin: -0.3rem 0 0.9rem; font-size: 0.86rem; color: var(--text-muted); }
.rf-units strong { color: var(--text-primary); }

/* --- relations and the local graph --------------------------------------- */
.rf-rel { list-style: none; margin: 0; padding: 0; }
.rf-rel li { padding: 0.45rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.rf-rel li:last-child { border-bottom: 0; }
.rf-rel__k { display: block; font-size: 0.74rem; color: var(--text-muted); font-family: 'JetBrains Mono', ui-monospace, monospace; }
/* The local graph (SPE-85): printed by scripts/reference/local-graph.mjs, three pictures of it. The card's own
   width picks one (a container query, not the screen's: the sidebar arrives at 1040 px and narrows the card), so
   the ring is drawn 1 : 1 at 760 or at 500, and below 500 the phone picture (pill on top, two trunks) takes over.
   Faded by colour, never transparency. */
.rf-lg-card { container-type: inline-size; }
.rf-lg { display: block; width: 100%; height: auto; margin: 0 auto; }
.rf-lg--wide { max-width: 760px; }
.rf-lg--mid { display: none; max-width: 500px; }
.rf-lg--narrow { display: none; max-width: 360px; }
@container (max-width: 759.98px) { .rf-lg--wide { display: none; } .rf-lg--mid { display: block; } }
@container (max-width: 499.98px) { .rf-lg--mid { display: none; } .rf-lg--narrow { display: block; } }
.rf-lg__h { font: 600 10.5px Inter, system-ui, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; fill: var(--text-muted); }
.rf-lg__none { font: italic 400 12px Inter, system-ui, sans-serif; fill: var(--text-muted); }
.rf-lg__e { fill: none; stroke: var(--text-muted); stroke: color-mix(in srgb, var(--text-muted) 55%, var(--bg-surface)); stroke-width: 1.2; }
.rf-lg__a { fill: var(--text-muted); }
.rf-lg__d { fill: var(--bg-surface); stroke: var(--text-primary); stroke-width: 1.4; }
.rf-lg__d--fill { fill: var(--text-primary); }
.rf-lg__d--dot { stroke-dasharray: 1.5 2; }
.rf-lg__t { font: 500 12.5px Inter, system-ui, sans-serif; fill: var(--text-primary); }
.rf-lg__r { font: 400 11px Inter, system-ui, sans-serif; fill: var(--text-muted); }
.rf-lg__me rect { fill: var(--bg-elevated); stroke: var(--accent); stroke-width: 2; }
.rf-lg__t--me { font-weight: 700; font-size: 13px; }
.rf-lg__n { cursor: pointer; }
.rf-lg__n:focus { outline: none; }
.rf-lg__n:focus-visible .rf-lg__t { text-decoration: underline; }
/* a hover or focus lights the one neighbour — its line, arrow, dot and name — and the rest turn muted */
.rf-lg:has(.rf-lg__n:hover, .rf-lg__n:focus-visible) .rf-lg__n:not(:hover):not(:focus-visible) .rf-lg__t { fill: var(--text-muted); }
.rf-lg:has(.rf-lg__n:hover, .rf-lg__n:focus-visible) .rf-lg__n:not(:hover):not(:focus-visible) .rf-lg__d { stroke: var(--text-muted); }
.rf-lg:has(.rf-lg__n:hover, .rf-lg__n:focus-visible) .rf-lg__n:not(:hover):not(:focus-visible) .rf-lg__d--fill { fill: var(--text-muted); }
.rf-lg__n:hover .rf-lg__e, .rf-lg__n:focus-visible .rf-lg__e { stroke: var(--accent); stroke-width: 2; }
.rf-lg__n:hover .rf-lg__a, .rf-lg__n:focus-visible .rf-lg__a { fill: var(--accent); }
.rf-lg__n:hover .rf-lg__d, .rf-lg__n:focus-visible .rf-lg__d { stroke: var(--accent); stroke-width: 2; }
.rf-lg__n:hover .rf-lg__d--fill, .rf-lg__n:focus-visible .rf-lg__d--fill { fill: var(--accent); }
.rf-lg__n:hover .rf-lg__t, .rf-lg__n:focus-visible .rf-lg__t { fill: var(--accent); font-weight: 600; }
.rf-lg-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; margin: 0.7rem 0 0; font-size: 0.8rem; color: var(--text-muted); }
.rf-lg-legend svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 0.35rem; }
/* printed: dark ink on white whatever the theme — the four state glyphs stay four (solid, half, double, dotted)
   and a hollow dot stays white, not the dark theme's surface (Codex, SPE-82) */
@media print {
  .rf-lg-card { --text-primary: #111; --text-muted: #444; --accent: #111; --bg-surface: #fff; --bg-elevated: #fff; --border: #999;
    color: #111; background: #fff; break-inside: avoid; }
}

/* --- "How the calculator works" ------------------------------------------- */
.rf-flow { position: relative; margin: 0 0 1.6rem; }
.rf-flow__r { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rf-flow__bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.6rem; }
.rf-flow__bar label { cursor: pointer; border: 1px solid var(--border); border-radius: 2px; padding: 0.4rem 0.75rem; font-size: 0.86rem; background: var(--bg-surface); }
#rf-show-ladder:checked ~ .rf-flow__bar label[for="rf-show-ladder"],
#rf-show-trunking:checked ~ .rf-flow__bar label[for="rf-show-trunking"],
#rf-show-all:checked ~ .rf-flow__bar label[for="rf-show-all"] { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.14); }
#rf-show-ladder:focus-visible ~ .rf-flow__bar label[for="rf-show-ladder"],
#rf-show-trunking:focus-visible ~ .rf-flow__bar label[for="rf-show-trunking"],
#rf-show-all:focus-visible ~ .rf-flow__bar label[for="rf-show-all"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.rf-flow__note { display: none; font-size: 0.86rem; color: var(--text-muted); margin: 0 0 0.8rem; }
#rf-show-ladder:checked ~ .rf-flow__note--ladder, #rf-show-trunking:checked ~ .rf-flow__note--trunking, #rf-show-all:checked ~ .rf-flow__note--all { display: block; }
.rf-flow__fig { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-surface); }
.rf-flow__svg { display: block; width: 100%; min-width: 880px; height: auto; }
.rf-flow__head { font-family: Inter, system-ui, sans-serif; font-size: 11.5px; font-weight: 600; fill: var(--text-muted); letter-spacing: 0.02em; }
.rf-e { fill: none; stroke: var(--border); stroke-width: 1; }
.rf-fn rect { fill: var(--bg-elevated); stroke: var(--border); stroke-width: 1; }
.rf-fn__t { font-family: Inter, system-ui, sans-serif; font-size: 12px; font-weight: 500; fill: var(--text-primary); }
.rf-fn__s { font-family: Inter, system-ui, sans-serif; font-size: 10px; fill: var(--text-muted); }
.rf-fn:hover rect, .rf-fn:focus-visible rect { stroke: var(--accent); stroke-width: 2; }
.rf-fn:focus-visible { outline: none; }
#rf-show-ladder:checked ~ .rf-flow__fig .rf-fn.u-ladder rect,
#rf-show-trunking:checked ~ .rf-flow__fig .rf-fn.u-trunking rect,
#rf-show-all:checked ~ .rf-flow__fig .rf-fn rect { stroke: var(--accent); stroke-width: 2; }
#rf-show-ladder:checked ~ .rf-flow__fig .rf-fn.u-ladder .rf-fn__t,
#rf-show-trunking:checked ~ .rf-flow__fig .rf-fn.u-trunking .rf-fn__t { font-weight: 700; }
/* faded by colour, never by transparency: an opaque box keeps the wires behind it hidden */
#rf-show-ladder:checked ~ .rf-flow__fig .rf-fn:not(.u-ladder) .rf-fn__t,
#rf-show-trunking:checked ~ .rf-flow__fig .rf-fn:not(.u-trunking) .rf-fn__t,
#rf-show-ladder:checked ~ .rf-flow__fig .rf-fn:not(.u-ladder) .rf-fn__s,
#rf-show-trunking:checked ~ .rf-flow__fig .rf-fn:not(.u-trunking) .rf-fn__s { fill: var(--text-muted); opacity: 0.75; }
#rf-show-ladder:checked ~ .rf-flow__fig .rf-fn:not(.u-ladder) rect,
#rf-show-trunking:checked ~ .rf-flow__fig .rf-fn:not(.u-trunking) rect { fill: var(--bg-surface); stroke-dasharray: 3 3; }
#rf-show-ladder:checked ~ .rf-flow__fig .rf-e.u-ladder,
#rf-show-trunking:checked ~ .rf-flow__fig .rf-e.u-trunking { stroke: var(--accent); stroke-width: 1.6; }
.rf-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; font-size: 0.8rem; color: var(--text-muted); margin-top: 0.6rem; }
.rf-legend i { display: inline-block; width: 1.5rem; height: 0.8rem; margin-right: 0.45rem; vertical-align: -0.1rem; border-radius: 2px; }
.rf-legend__used { border: 2px solid var(--accent); }
.rf-legend__idle { border: 1px solid var(--border); opacity: 0.8; }

/* --- lists --------------------------------------------------------------- */
.rf-lists { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.2rem 2rem; margin: 0 0 1.4rem; }
@media (min-width: 900px) { .rf-lists { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rf-list h2 { font-size: 1rem; margin: 0 0 0.5rem; }
.rf-list ul { list-style: none; margin: 0; padding: 0; }
.rf-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.rf-calc { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 0 0 1.6rem; }
.rf-calc h2 { font-size: 1.1rem; margin: 0 0 0.4rem; }
.rf-calc p { margin: 0; }

/* --- the whole-library graph (step 2) -------------------------------------
   Printed by the generator, moved and lit by tools/refgraph/runtime.js; without script the section
   stays hidden. FADED BY COLOUR, NEVER BY TRANSPARENCY: a box stays opaque, so no wire shows through. */
.rg { margin: 0 0 2.2rem; }
.rg-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin: 0 0 0.6rem; }
.rg-title { font-size: 1.2rem; margin: 0; flex: 1 1 auto; }
.rg-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin: 0 0 0.5rem; }
.rg-chips, .rg-zoom { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.rg-chip, .rg-zoom button, .rg-toggle { font: inherit; font-size: 0.84rem; min-height: 2.25rem; padding: 0.3rem 0.75rem; border: 1px solid var(--border);
  border-radius: 2px; background: transparent; color: var(--text-muted); cursor: pointer; }
.rg-zoom button { min-width: 2.5rem; }
.rg-chip:hover, .rg-zoom button:hover, .rg-toggle:hover { border-color: var(--accent); color: var(--text-primary); }
.rg-chip:focus-visible, .rg-zoom button:focus-visible, .rg-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rg-chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-text); background: var(--bg-elevated); font-weight: 600; }
.rg-toggle { display: none; color: var(--text-primary); }
.rg-help { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 0.6rem; max-width: 90ch; }
.rg-wrap { position: relative; }
.rg-stage { position: relative; }
.rg-hint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); margin: 0; padding: 0.35rem 0.75rem; font-size: 0.82rem;
  background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border); border-radius: 2px; pointer-events: none; display: none; }
.rg[data-hint="wheel"] .rg-hint { display: block; }
.rg-stage { height: clamp(460px, 78vh, 900px); border: 1px solid var(--border); border-radius: 4px; background: var(--bg-surface); overflow: hidden; }
.rg-svg { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.rg-svg:active { cursor: grabbing; }
.rg-head { font-family: Inter, system-ui, sans-serif; font-size: 12px; font-weight: 600; fill: var(--text-muted); }
.rg-fam { font-family: Inter, system-ui, sans-serif; font-size: 10.5px; fill: var(--text-muted); }
.rg-e { fill: none; stroke: var(--border); stroke-width: 1.1; }
.rg-e--namedBy { stroke-dasharray: 2 3; }
.rg-e--supersedes { stroke-dasharray: 5 3; }
.rg-e--contradicts { stroke: var(--accent-warm); stroke-dasharray: 5 3; }
.rg-node { cursor: pointer; }
.rg-node:focus { outline: none; }
.rg-box { fill: var(--bg-elevated); stroke: var(--border); stroke-width: 1; }
.rg-st--estimated .rg-box { stroke-dasharray: 4 2; }
.rg-st--choice .rg-box { stroke-dasharray: 1 2; }
.rg-st--absent .rg-box { stroke-dasharray: 1 3; }
.rg-t { font-family: Inter, system-ui, sans-serif; font-size: 11.5px; font-weight: 500; fill: var(--text-primary); pointer-events: none; }
.rg-mark { fill: none; stroke: var(--text-muted); stroke-width: 1; pointer-events: none; }
.rg-mark--fill { fill: var(--text-muted); }
.rg-mark--dot { stroke-dasharray: 1 1.5; }
.rg-node:hover .rg-box, .rg-node:focus-visible .rg-box { stroke: var(--accent); stroke-width: 2; }
/* a chip's set, and a selection: lit by the accent, the rest faded by colour */
.rg-node[data-show="sel"] .rg-box { stroke: var(--accent); stroke-width: 2.5; fill: var(--bg-primary); }
.rg-node[data-show="sel"] .rg-t { font-weight: 700; }
.rg-node[data-show="near"] .rg-box { stroke: var(--accent); stroke-width: 1.5; }
.rg-node[data-show="far"] .rg-box, .rg-node[data-show="out"] .rg-box { fill: var(--bg-surface); }
.rg-node[data-show="far"] .rg-t, .rg-node[data-show="out"] .rg-t { fill: var(--text-muted); font-weight: 400; }
.rg-e[data-show="on"] { stroke: var(--accent); stroke-width: 2; }
.rg-e--contradicts[data-show="on"] { stroke: var(--accent-warm); }
/* the side panel: over the stage on a wide screen, below it on a phone */
.rg-panel { position: absolute; right: 12px; bottom: 12px; width: min(330px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto;
  box-sizing: border-box; padding: 0.85rem 1rem 1rem; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); }
.rg-panel[hidden] { display: none; }
.rg-panel__x { position: absolute; top: 0.35rem; right: 0.4rem; min-width: 2.25rem; min-height: 2.25rem; font: inherit; font-size: 1.2rem; line-height: 1;
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer; }
.rg-panel__x:hover, .rg-panel__x:focus-visible { color: var(--text-primary); }
.rg-panel__id { margin: 0 2rem 0.25rem 0; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.72rem; color: var(--text-muted); overflow-wrap: anywhere; }
.rg-panel__t { margin: 0 2rem 0.5rem 0; font-size: 1rem; line-height: 1.3; }
.rg-panel__what { margin: 0.6rem 0 0.7rem; font-size: 0.86rem; color: var(--text-muted); }
.rg-panel__h { margin: 0.6rem 0 0.25rem; font-size: 0.74rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.rg-panel__list { list-style: none; margin: 0; padding: 0; font-size: 0.86rem; }
.rg-panel__list li { padding: 0.15rem 0; }
.rg-panel__go { font: inherit; padding: 0.15rem 0; border: 0; background: none; color: var(--accent-text); cursor: pointer; text-align: left; }
.rg-panel__go:hover, .rg-panel__go:focus-visible { text-decoration: underline; }
.rg-panel__k { margin-left: 0.4em; font-size: 0.76rem; color: var(--text-muted); }
.rg-panel__open { margin: 0 0 0.3rem; }
@media (max-width: 700px) {
  /* a phone: the lists are the instrument, the picture is one tap away */
  .rg-toggle { display: inline-flex; align-items: center; }
  .rg:not([data-open="true"]) .rg-body { display: none; }
  .rg-stage { height: 72vh; }
  /* the panel becomes a sheet over the stage's lower part; the runtime keeps the box above it */
  .rg-panel { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 55%; }
}
@media print { .rg { display: none; } }

@media print {
  .rf-flow__bar, .rf-flow__note { display: none !important; }
  .rf-group:not([open]) > *:not(summary) { display: block; }
}
