/* Only explicitly loaded by the three audited RL pages. Inherit site colors. */
body.rl-formula-modal-open { overflow: hidden; }
.rl-fh-formula { display: block; min-width: 0; margin: 24px 0 30px; }
.rl-fh-formula .katex-display { margin-bottom: 12px; }
.rl-fh-hint { display: block; color: var(--muted); font-size: 14px; line-height: 1.7; margin: 8px 0 10px; }
.rl-fh-target { color: var(--accent); border: 0; cursor: pointer; pointer-events: auto; }
.rl-fh-formula .katex-display::after { content: ""; display: block; width: 48px; margin: 12px auto 0; border-bottom: 2px dotted var(--accent); }
.rl-fh-target:hover { background: var(--accent-soft, var(--quote-bg)); }
.rl-fh-trigger { min-height: 44px; max-width: 100%; text-align: left; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--fg); font: inherit; font-size: 15px; line-height: 1.7; cursor: pointer; overflow-wrap: anywhere; }
.rl-fh-trigger:hover { border-color: var(--accent); background: var(--quote-bg); }
.rl-fh-target:focus-visible { outline: none; background: var(--accent-soft, var(--quote-bg)); }
.rl-fh-formula:focus-within .katex-display { outline: 2px solid var(--accent); outline-offset: 5px; }
.rl-fh-trigger:focus-visible,
#rl-formula-help-dialog :is(button, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--accent); outline-offset: 4px;
}
#rl-formula-help-dialog {
  position: fixed; inset: 0; margin: auto; min-height: 0;
  width: min(660px, calc(100vw - 28px)); max-width: calc(100vw - 28px);
  height: min(760px, calc(100vh - 28px)); height: min(760px, calc(100dvh - 28px));
  max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px);
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--card); color: var(--fg); font: inherit;
  box-sizing: border-box; overflow: clip; overscroll-behavior: contain; box-shadow: 0 20px 70px rgba(0,0,0,.25);
}
#rl-formula-help-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
#rl-formula-help-dialog::backdrop { background: rgba(0,0,0,.45); }
#rl-formula-help-dialog .rl-fh-header {
  position: relative; inset: auto; width: auto; height: auto; min-height: 0; max-width: none;
  margin: 0; float: none; transform: none; z-index: 1; text-align: left;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 24px; border-bottom: 1px solid var(--border); background: var(--card);
}
#rl-formula-help-dialog .rl-fh-header > div { min-width: 0; }
#rl-formula-help-dialog .rl-fh-eyebrow { margin: 0 0 8px; font-size: 13px; line-height: 1.6; color: var(--muted); }
#rl-formula-help-dialog h2 { margin: 0; padding: 0; border: 0; font-size: 22px; line-height: 1.5; color: var(--fg); overflow-wrap: anywhere; }
#rl-formula-help-dialog .rl-fh-close {
  width: 44px; height: 44px; flex-shrink: 0; padding: 0; font: inherit;
  font-size: 28px; line-height: 1; cursor: pointer; color: var(--fg);
  background: var(--quote-bg); border: 1px solid var(--border); border-radius: 9px;
}
#rl-formula-help-dialog .rl-fh-body { position: relative; min-height: 0; overflow: auto; contain: paint; overscroll-behavior: contain; scroll-behavior: auto; padding: 22px 24px 28px; }
#rl-formula-help-dialog h3 { margin: 22px 0 8px; font-size: 16px; line-height: 1.6; color: var(--fg); padding: 0; border: 0; }
#rl-formula-help-dialog p { margin: 0 0 16px; font-size: 16px; line-height: 1.85; overflow-wrap: anywhere; }
#rl-formula-help-dialog .rl-fh-selected,
#rl-formula-help-dialog .rl-fh-context { max-width: 100%; overflow-x: auto; padding: 14px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--quote-bg); }
#rl-formula-help-dialog .katex-display { margin: 6px 0; padding: 0; border: 0; background: transparent; }
#rl-formula-help-dialog .katex-display > .katex { min-width: max-content; }
#rl-formula-help-dialog .rl-fh-example { margin: 20px 0; padding: 16px 18px; border-left: 3px solid var(--accent); border-radius: 8px; background: var(--quote-bg); }
#rl-formula-help-dialog .rl-fh-example h3 { margin-top: 0; }
#rl-formula-help-dialog .rl-fh-example p { margin-bottom: 0; }
#rl-formula-help-dialog details { margin: 22px 0 0; padding: 0; border: 0; background: transparent; }
#rl-formula-help-dialog summary { cursor: pointer; min-height: 44px; padding: 8px 0; line-height: 1.75; font-size: 16px; }
#rl-formula-help-dialog .rl-fh-footer { position: relative; inset: auto; width: auto; height: auto; margin: 0; float: none; transform: none; z-index: 1; padding: 14px 24px; text-align: left; border-top: 1px solid var(--border); background: var(--card); }
#rl-formula-help-dialog .rl-fh-footer button { min-height: 44px; padding: 9px 16px; font: inherit; font-size: 16px; line-height: 1.6; cursor: pointer; border: 1px solid var(--border); border-radius: 9px; color: var(--fg); background: var(--quote-bg); }
@media (max-width: 500px) {
  #rl-formula-help-dialog .rl-fh-header { padding: 16px; gap: 10px; }
  #rl-formula-help-dialog h2 { font-size: 20px; }
  #rl-formula-help-dialog .rl-fh-body { padding: 18px 16px 22px; }
  #rl-formula-help-dialog .rl-fh-footer { padding: 12px 16px; }
  #rl-formula-help-dialog .rl-fh-footer button { width: 100%; }
}
