/* The linked multispike inspector stays in document flow on every screen. */
.sgd-mech {
  --mech-ink: #213735;
  --mech-muted: #506461;
  --mech-line: #cfdbd4;
  --mech-soft: #f3f6f0;
  --mech-weak: #b05f3b;
  --mech-strong: #b0820f;
  --mech-other: #9a4786;
  --mech-nuisance: #317aa6;
  /* Hover emphasis follows the same component marks as both histories. */
  --ra-c-weak: var(--mech-weak); --ra-c-weak-soft: #f6e3d9;
  --ra-c-strong: var(--mech-strong); --ra-c-strong-soft: #fff1bd; --ra-c-strong-text: #7b590e;
  --ra-c-other: var(--mech-other); --ra-c-other-soft: #f1e2ed;
  --ra-c-nuisance: var(--mech-nuisance); --ra-c-nuisance-soft: #e1f0f9;
  color: var(--mech-ink);
  margin: 2rem auto;
  border: 1px solid var(--mech-line);
  border-radius: 1rem;
  padding: clamp(1rem, 2.5vw, 2rem);
  background: #fffefa;
  min-width: 0;
  scroll-margin-top: 6rem;
  font-size: 1rem;
  line-height: 1.6;
}
.sgd-mech *, .sgd-mech *::before, .sgd-mech *::after { box-sizing: border-box; }
.sgd-mech [hidden] { display: none !important; }
.sgd-mech [data-experiment-pending] { opacity: .55; }
.sgd-mech [data-experiment-pending] [data-experiment-pending] { opacity: 1; }
.sgd-mech p { margin: .8rem 0; max-width: 85ch; }
.sgd-mech a { text-decoration-thickness: .08em; text-underline-offset: .17em; }
.sgd-mech h3, .sgd-mech h4, .sgd-mech h5 { color: var(--mech-ink); line-height: 1.25; }
.sgd-mech h3 { font-size: clamp(1.4rem, 2.4vw, 2rem); margin: .25rem 0 .7rem; }
.sgd-mech h4 { font-size: 1.2rem; margin: 1.4rem 0 .65rem; }
.sgd-mech h5 { font-size: 1.05rem; margin: 1.3rem 0 .6rem; }
.sgd-mech-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1.5rem; }
.sgd-mech-heading > p { color: var(--mech-muted); font-size: .9rem; max-width: 28rem; }
.sgd-mech .eyebrow { margin: 0; font-size: .8rem; letter-spacing: .06em; }
.sgd-mech-status, .sgd-mech-orientation, .sgd-mech-note { background: var(--mech-soft); border-left: 3px solid var(--mech-line); padding: .65rem .9rem; }
.sgd-mech-status:empty, .sgd-mech-note:empty { display: none; }
.sgd-mech-expectation p, .sgd-mech-target-outcome p { margin: .35rem 0; }
.sgd-mech-expectation p:first-child { color: var(--mech-muted); font-size: .9rem; }
.sgd-mech-target-outcome { font-variant-numeric: tabular-nums; }
.sgd-mech-local-directions { margin: 1rem 0; padding-top: 1rem; border-top: 1px solid var(--mech-line); }
#sgdMechOffsetBridge { scroll-margin-top: 8rem; }
.sgd-mech button, .sgd-mech select, .sgd-mech input { font: inherit; }
.sgd-mech button, .sgd-mech select, .sgd-mech input[type="number"], .sgd-mech #sgdMechDownloadSettings {
  min-height: 2.75rem;
  border: 1px solid #9eb2a7;
  border-radius: .45rem;
  color: var(--mech-ink);
  background: #fff;
  padding: .45rem .7rem;
  max-width: 100%;
}
.sgd-mech #sgdMechDownloadSettings { display: inline-flex; align-items: center; font: inherit; text-decoration: underline; }
.sgd-mech #sgdMechDownloadSettings:not([href]) { opacity: .55; }
.sgd-mech button { cursor: pointer; line-height: 1.3; white-space: normal; }
.sgd-mech button:hover:not(:disabled) { background: #eaf1e8; color: var(--mech-ink); border-color: #5c7b69; }
.sgd-mech button[aria-pressed="true"] { background: #234d3b; color: #fff; border-color: #234d3b; }
.sgd-mech :is(button, input, select):disabled { opacity: .55; cursor: default; }
.sgd-mech :is(button, input, select, summary, a, [tabindex]):focus-visible { outline: 3px solid #9b4f14; outline-offset: 3px; }
.sgd-mech input[type="range"] { flex: 0 0 auto; width: 100%; min-height: 2.5rem; height: 2.5rem; margin: .25rem 0; accent-color: #2b7855; cursor: pointer; }
.sgd-mech input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: #2b7855; }
.sgd-mech-toolbar, .sgd-mech-actions, .sgd-mech-share, .sgd-mech-segment { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.sgd-mech-toolbar, .sgd-mech-actions, .sgd-mech-share { margin: 1rem 0; }
.sgd-mech-segment { gap: .25rem; }
.sgd-mech-segment button { min-width: 3.3rem; }
.sgd-mech-score-grid, .sgd-mech-control-grid, .sgd-mech-two-plots, .sgd-mech-equation-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.sgd-mech-score-grid { margin: 1rem 0 .5rem; }
.sgd-mech-score-grid article { background: var(--mech-soft); border: 1px solid var(--mech-line); border-radius: .65rem; padding: 1rem; min-width: 0; }
.sgd-mech-score-grid h4 { margin: 0 0 .6rem; }
.sgd-mech-score-grid p { font-size: .9rem; margin-bottom: 0; color: var(--mech-muted); }
.sgd-mech-metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .7rem 1.1rem; margin: .5rem 0; }
.sgd-mech-metrics > div { min-width: 0; }
.sgd-mech-metrics dt { font-size: .85rem; line-height: 1.4; color: var(--mech-muted); }
.sgd-mech-metrics dd { font-size: 1.2rem; margin: .2rem 0 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sgd-mech-metrics .sgd-mech-primary { grid-column: 1 / -1; }
.sgd-mech-primary dd { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 650; line-height: 1.15; }
.sgd-mech-ledger-metrics { grid-template-columns: repeat(4, minmax(0,1fr)); border-block: 1px solid var(--mech-line); padding: .9rem 0; }
.sgd-mech-baseline { color: var(--mech-muted); font-size: .9rem; }
.sgd-mech-cohort { border-block: 1px solid var(--mech-line); margin: 1rem 0; padding: .35rem 0; }
.sgd-mech-cohort strong { font-variant-numeric: tabular-nums; }
.sgd-mech-key { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: 1.4rem 0 .5rem; font-size: .85rem; }
.sgd-mech-key > span { display: inline-flex; align-items: center; gap: .45rem; color: var(--mech-ink); }
.sgd-mech-key > .ra-show-diagram { order: 1; margin-inline-start: auto; }
.sgd-mech-key > span::before { content: ""; width: 1.2rem; height: .28rem; background: currentColor; }
.sgd-mech-key > [data-raw="true"]::before { width: .32rem; height: .32rem; border-radius: 50%; margin-inline: .44rem; }
.sgd-mech-key > .sgd-mech-mean::before { height: 0; background: transparent; border-top: 2px dashed currentColor; }
.sgd-mech-weak { color: var(--mech-weak); }
.sgd-mech-strong { color: var(--mech-strong); }
.sgd-mech-other { color: var(--mech-other); }
.sgd-mech-nuisance { color: var(--mech-nuisance); }
.sgd-mech-mean { color: #263d39; }
.sgd-mech-key > .sgd-mech-weak::before { background: var(--mech-weak); }
.sgd-mech-key > .sgd-mech-strong::before { background: var(--mech-strong); }
.sgd-mech-key > .sgd-mech-other::before { background: var(--mech-other); }
.sgd-mech-key > .sgd-mech-nuisance::before { background: var(--mech-nuisance); }
.sgd-mech-figure { min-width: 0; margin: .85rem 0; background: #fff; border: 1px solid var(--mech-line); border-radius: .6rem; padding: .8rem; }
.sgd-mech-figure figcaption { line-height: 1.35; margin-bottom: .5rem; }
.sgd-mech-figure figcaption strong { display: block; font-size: 1rem; }
.sgd-mech-figure figcaption span { display: block; margin-top: .35rem; color: var(--mech-muted); font-size: .86rem; }
.sgd-mech-figure svg { width: 100%; height: auto; display: block; min-height: 12rem; overflow: visible; }
.sgd-mech-figure svg text { font-family: inherit; fill: var(--mech-muted); }
.sgd-mech-figure svg .axis, .sgd-mech-figure svg .grid { stroke: var(--mech-line); }
.sgd-mech-figure svg .cursor { stroke: #273b37; stroke-dasharray: 3 3; }
.sgd-mech-figure svg [data-index] { cursor: pointer; }
.sgd-mech-cursor { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.sgd-mech-cursor label { flex: 1 1 16rem; font-weight: 600; }
.sgd-mech-cursor output { font-variant-numeric: tabular-nums; }
.sgd-mech-control-grid { margin: .8rem 0; align-items: start; }
.sgd-mech-control-grid label, .sgd-mech-weight-grid label { display: flex; flex-direction: column; gap: .4rem; font-weight: 600; min-width: 0; }
.sgd-mech-control-grid label { font-size: .9rem; }
.sgd-mech-control-grid output { font-weight: 400; font-variant-numeric: tabular-nums; }
.sgd-mech-local-comparison { margin: 1.5rem 0 .6rem; padding: .75rem 1rem; background: var(--mech-soft); border-radius: .6rem; }
.sgd-mech-local-comparison .sgd-mech-actions { margin: .4rem 0; }
.sgd-mech-local-comparison p { margin: .4rem 0; }
.sgd-mech-cohort-details { margin: .6rem 0; }
.sgd-mech-cohort-details > summary { cursor: pointer; padding: .5rem 0; }
.sgd-mech-return { margin-block: 1rem; }
#sgdMechHistory { scroll-margin-top: 6rem; }
.sgd-mech-control-grid select, .sgd-mech-control-grid input[type="number"] { width: 100%; font-weight: 400; }
.sgd-mech-check { display: flex; align-items: center; gap: .6rem; margin: .8rem 0; }
.sgd-mech-workbench, .sgd-mech-depth, .sgd-mech-settings, .sgd-mech-mixer { border: 1px solid var(--mech-line); border-radius: .6rem; margin: 1rem 0; background: #fff; min-width: 0; scroll-margin-top: 6rem; }
.sgd-mech-workbench > summary, .sgd-mech-depth > summary, .sgd-mech-settings > summary, .sgd-mech-mixer > summary { padding: .9rem 1rem; cursor: pointer; font-weight: 650; line-height: 1.45; }
.sgd-mech-workbench > summary { background: var(--mech-soft); border-radius: .6rem; }
.sgd-mech details[open] > summary { border-bottom: 1px solid var(--mech-line); }
.sgd-mech .drawer-meta { font-size: .85rem; font-weight: 400; line-height: 1.4; margin-top: .3rem; color: var(--mech-muted); }
.sgd-mech-detail-body { padding: .2rem 1rem 1rem; min-width: 0; }
.sgd-mech-depth-group > h4 { margin-top: 1.75rem; }
.sgd-mech-equation { padding: .65rem .3rem; margin: .65rem 0; overflow-x: auto; max-width: 100%; }
.sgd-mech-equation .katex-display { margin: .3rem 0; }
.sgd-mech-equation-pair > section { min-width: 0; padding: .5rem .75rem; border: 1px solid var(--mech-line); border-radius: .5rem; }
.sgd-mech-equation-pair h5 { margin-top: .3rem; }
.sgd-mech-table-scroll { max-width: 100%; min-width: 0; overflow-x: auto; margin: .9rem 0; border: 1px solid var(--mech-line); border-radius: .35rem; }
.sgd-mech-table { width: 100%; border-collapse: collapse; font-size: .9rem; text-align: left; line-height: 1.45; }
.sgd-mech-table caption { text-align: left; padding: .65rem .7rem; color: var(--mech-muted); font-weight: 600; }
.sgd-mech-table-title { font-weight: 600; color: var(--mech-muted); }
.sgd-mech .sgd-mech-metric-note { margin-top: .35rem; font-size: .85rem; font-weight: 400; line-height: 1.4; }
.sgd-mech-mechanism { padding: .75rem; border-left: 3px solid var(--mech-weak); background: var(--mech-soft); }
.sgd-mech-table th, .sgd-mech-table td { padding: .6rem .7rem; vertical-align: top; border-bottom: 1px solid #e1e7e2; font-variant-numeric: tabular-nums; }
.sgd-mech-table thead th { background: var(--mech-soft); font-weight: 650; }
.sgd-mech-table tbody th { font-weight: 550; }
.sgd-mech-table tr:last-child > * { border-bottom: 0; }
.sgd-mech-table td { overflow-wrap: anywhere; }
.sgd-mech-map { font-size: 14px; width: max-content; min-width: 100%; }
.sgd-mech-map th, .sgd-mech-map td { min-width: 4.3rem; padding: .5rem; text-align: right; white-space: nowrap; }
.sgd-mech-map th:first-child { position: sticky; left: 0; background: var(--mech-soft); z-index: 1; }
.sgd-mech-map button { min-height: 2rem; padding: .2rem; border: 0; background: transparent; width: 100%; }
.sgd-mech-definition-list { margin: 1rem 0; }
.sgd-mech-definition-list > div { display: grid; grid-template-columns: minmax(8rem, 1fr) 3fr; gap: 1rem; border-top: 1px solid var(--mech-line); padding: .5rem 0; }
.sgd-mech-definition-list dt { font-weight: 650; }
.sgd-mech-definition-list dd { margin: 0; }
.sgd-mech-mixer > p, .sgd-mech-mixer > .sgd-mech-equation { margin-inline: 1rem; }
.sgd-mech-weight-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .8rem; padding: .5rem 1rem 1rem; }
.sgd-mech-weight-grid label { font-size: .85rem; padding: .7rem; border: 1px solid var(--mech-line); border-radius: .4rem; }
.sgd-mech-weight-grid input { width: 100%; }
.sgd-mech-weight-grid output { font-size: .8rem; font-weight: 400; color: var(--mech-muted); overflow-wrap: anywhere; }
.sgd-mech pre { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; font-size: .82rem; line-height: 1.6; padding: .8rem; background: var(--mech-soft); border-radius: .4rem; }
.sgd-mech-static { padding: 1rem; background: var(--mech-soft); border: 1px solid var(--mech-line); border-radius: .6rem; }
@media (max-width: 760px) {
  .sgd-mech { padding: 1rem; }
  .sgd-mech-score-grid, .sgd-mech-two-plots, .sgd-mech-equation-pair { grid-template-columns: 1fr; }
  .sgd-mech-ledger-metrics, .sgd-mech-weight-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .sgd-mech-figure { padding: .65rem; }
  .sgd-mech-figure svg { min-height: 13rem; }
  .sgd-mech-table { font-size: .87rem; }
  .sgd-mech-map { font-size: 14px; }
}
@media (max-width: 460px) {
  .sgd-mech { padding: .8rem; border-radius: .65rem; }
  .sgd-mech-control-grid { grid-template-columns: 1fr; }
  .sgd-mech-detail-body { padding-inline: .7rem; }
  .sgd-mech-workbench > summary, .sgd-mech-depth > summary, .sgd-mech-settings > summary, .sgd-mech-mixer > summary { padding-inline: .7rem; }
  .sgd-mech-definition-list > div { grid-template-columns: 1fr; gap: .2rem; }
  .sgd-mech-weight-grid { padding-inline: .6rem; gap: .55rem; }
  .sgd-mech-weight-grid label { padding: .55rem; }
  .sgd-mech-figure figcaption span { font-size: .85rem; }
  .sgd-mech-table { min-width: 27rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sgd-mech *, .sgd-mech *::before, .sgd-mech *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .sgd-mech { border: 0; padding: 0; }
  .sgd-mech button, .sgd-mech-share { display: none; }
  .sgd-mech-figure, .sgd-mech-score-grid article { break-inside: avoid; }
}

.sgd-mech button[aria-pressed="true"]:hover:not(:disabled) { background: #193f2f; color: #fff; }
#sgdMechCohortTableBody td, #sgdMechRowBody td, #sgdMechFunctionTableBody td,
#sgdMechUnitDirectionComparison td, #sgdMechSpectralComparison td { white-space: nowrap; overflow-wrap: normal; }
#sgdMechRowArithmeticNote { white-space: normal; overflow-wrap: anywhere; }
.sgd-mech-response-key > .sgd-mech-strong::before { height: 0; background: transparent; border-top: 3px dashed var(--mech-strong); }
.sgd-mech-response-key > .sgd-mech-other::before { height: 0; background: transparent; border-top: 3px dotted var(--mech-other); }
.sgd-mech-cost-key > span::before { width: .9rem; height: .9rem; border: 1px solid rgba(0,0,0,.15); }
.sgd-mech svg[data-cursor-plot="true"] { touch-action: pan-y; }
.sgd-mech-selected-row { background: #f3f6f0; }
.sgd-mech-selected-cell { box-shadow: inset 0 0 0 2px #9a4786; }

/* Keep corrections legible without repeating their scope in a third phone column. */
.sgd-mech-table .sgd-mech-number { white-space: nowrap; }
.sgd-mech-table .sgd-mech-group th { background: #edf2f6; padding-top: .7rem; }
#sgdMechCorrectionPanel .sgd-mech-table { min-width: 0; table-layout: fixed; }
#sgdMechCorrectionPanel .sgd-mech-table thead th:last-child { width: 7.2em; }
