/* MathCompute: shared by the visualizations (diagrams, residue colours) and each page's layout.
   Loads after compute.css; follows mathpages.css's rules (radius tokens, weights 400/600/700,
   44px controls, breakpoints 1180/960/760/520). Every colour has a dark value. */
:root {
  --res-0: #f6d7c8; --res-1: #d5e8e2; --res-2: #e4dcf2; --res-3: #f5e6b8;
  --res-4: #d6e2f3; --res-5: #f2d4df; --res-6: #dfe8c9; --res-7: #e6ddd3;
}
html[data-theme="dark"] {
  --res-0: #5a3529; --res-1: #1d4a43; --res-2: #3c3354; --res-3: #4d4224;
  --res-4: #253b55; --res-5: #4f2c3a; --res-6: #374325; --res-7: #3f3a35;
}
.cp-back { font-size: .875rem; font-weight: 700; text-decoration: none; }
.cp-back:hover { text-decoration: underline; }
.cp-main > p:first-child { margin: 0 0 6px; }

/* Young diagrams (young.js) */
.yd .yd-box rect { fill: var(--cp-box); stroke: var(--cp-box-line); stroke-width: 1; }
.yd .yd-box text { fill: var(--mp-ink); font-weight: 600; font-variant-numeric: tabular-nums; pointer-events: none; }
.yd .yd-inner rect { fill: var(--mp-surface-muted); stroke: var(--mp-border); stroke-dasharray: 3 3; }
.yd .is-rim rect { fill: var(--cp-rim); stroke: var(--cp-rim-line); stroke-width: 2; }
.yd .is-marked rect { fill: var(--cp-hook); stroke: var(--cp-corner); stroke-width: 2; }
.yd-empty { fill: var(--mp-muted); font-size: 20px; }
.yd .res-0 rect { fill: var(--res-0); } .yd .res-1 rect { fill: var(--res-1); } .yd .res-2 rect { fill: var(--res-2); }
.yd .res-3 rect { fill: var(--res-3); } .yd .res-4 rect { fill: var(--res-4); } .yd .res-5 rect { fill: var(--res-5); }
.yd .res-6 rect { fill: var(--res-6); } .yd .res-7 rect { fill: var(--res-7); }

/* Murnaghan–Nakayama */
.mn-paths { display: grid; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }
.mn-path { display: flex; align-items: center; gap: 14px; padding: 8px 12px; border: 1px solid var(--mp-border); border-left-width: 4px;
  border-radius: var(--mp-radius); background: var(--mp-surface); }
.mn-path.is-plus { border-left-color: var(--cp-rim-line); }
.mn-path.is-minus { border-left-color: var(--cp-corner); }
.mn-sign { flex: none; width: 2.5rem; margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.mn-steps { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.mn-steps figure { margin: 0; text-align: center; }
.mn-steps figcaption { color: var(--mp-muted); font-size: .75rem; }
.mn-table-panel { margin-top: 20px; overflow-x: auto; }
.mn-table { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .875rem; }
.mn-table caption { margin-bottom: 8px; color: var(--mp-muted); text-align: left; }
.mn-table th, .mn-table td { padding: 0; border: 1px solid var(--mp-border); text-align: center; }
.mn-table th { padding: 4px 8px; background: var(--mp-surface-muted); font-weight: 600; white-space: nowrap; }
.mn-cell { width: 100%; min-width: 2.4rem; min-height: 2rem; padding: 4px 6px; border: 0; background: transparent; color: var(--mp-ink); font: inherit; cursor: pointer; }
.mn-cell:hover { background: var(--mp-surface-soft); }
.mn-cell.is-negative { color: var(--cp-corner); font-weight: 600; }
.mn-cell.is-zero { color: var(--mp-muted); }
.mn-cell.is-current { outline: 3px solid var(--cp-rim-line); outline-offset: -3px; font-weight: 700; }

/* Blocks */
.bl-summary { margin-top: 1.6rem; }
.bl-detail { margin-bottom: 20px; }
.bl-detail h2 { margin-bottom: 12px; }
.bl-detail-row { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.bl-figure { margin: 0; }
.bl-figure h3 { margin: 0 0 8px; font: 700 1rem var(--mp-serif); }
.bl-figure figcaption { max-width: 18rem; margin-top: 6px; color: var(--mp-muted); font-size: .8125rem; }
.bl-quotient { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.bl-qpart { margin: 0; padding: 6px 8px; border-top: 4px solid var(--runner, var(--mp-border-strong)); text-align: center; }
.bl-qpart figcaption { color: var(--mp-muted); font-size: .75rem; }
.runner-0 { --runner: #c0603f; } .runner-1 { --runner: #2f8f83; } .runner-2 { --runner: #6b5aa6; } .runner-3 { --runner: #b08a2c; }
.runner-4 { --runner: #3d6fa8; } .runner-5 { --runner: #b04f72; } .runner-6 { --runner: #6c8a3a; } .runner-7 { --runner: #8a7a68; }
html[data-theme="dark"] .runner-0 { --runner: #e8957a; } html[data-theme="dark"] .runner-1 { --runner: #6cc5b6; }
html[data-theme="dark"] .runner-2 { --runner: #a998e0; } html[data-theme="dark"] .runner-3 { --runner: #e0bf68; }
html[data-theme="dark"] .runner-4 { --runner: #7fa8dc; } html[data-theme="dark"] .runner-5 { --runner: #e08aaa; }
html[data-theme="dark"] .runner-6 { --runner: #a8c47a; } html[data-theme="dark"] .runner-7 { --runner: #c2b3a2; }
.bl-bead { fill: var(--runner); }
.bl-blocks { display: grid; gap: 14px; }
.bl-block { padding: 12px 16px; border: 1px solid var(--mp-border); border-radius: var(--mp-radius-lg); background: var(--mp-surface); }
.bl-block.is-current { border-color: var(--cp-rim-line); box-shadow: inset 4px 0 0 var(--cp-rim-line); }
.bl-block h2 { margin: 0 0 8px; font: 700 1.05rem var(--mp-serif); }
.bl-parts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.bl-part { display: grid; place-items: center; min-width: 44px; min-height: 44px; padding: 5px; border: 1px solid var(--mp-border); border-radius: var(--mp-radius-sm);
  background: var(--mp-surface); cursor: pointer; }
.bl-part:hover { border-color: var(--mp-link); }
.bl-part.is-current { border-color: var(--cp-corner); box-shadow: 0 0 0 2px var(--cp-corner); }

/* RSK */
.rsk-word { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.rsk-letter { display: grid; place-items: center; min-width: 2.2rem; height: 2.2rem; border: 1px solid var(--mp-border); border-radius: var(--mp-radius-sm);
  background: var(--mp-surface); font-weight: 600; }
.rsk-letter.is-inserted { color: var(--mp-muted); background: var(--mp-surface-muted); }
.rsk-letter.is-current { border-color: var(--cp-corner); box-shadow: 0 0 0 2px var(--cp-corner); color: var(--mp-ink); }
.rsk-letter.is-lis { border-color: var(--cp-rim-line); background: var(--cp-rim); color: var(--mp-ink); }
.rsk-actions { margin: 0 0 16px; }
.rsk-stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* Residues and good nodes */
.yd .is-addable rect { fill-opacity: .55; stroke: var(--cp-box-line); stroke-dasharray: 4 3; }
.yd .is-addable text { fill: var(--mp-muted); }
.yd .is-normal rect, .yd .is-conormal rect { stroke: var(--cp-rim-line); stroke-width: 2.5; }
.yd .is-good rect { stroke: var(--cp-corner); stroke-width: 4; }
.yd .is-cogood rect { stroke: var(--cp-corner); stroke-width: 4; stroke-dasharray: 6 3; fill-opacity: 1; }
.yd .is-good, .yd .is-cogood { cursor: pointer; }
.yd .is-focus rect { filter: brightness(.88); }
html[data-theme="dark"] .yd .is-focus rect { filter: brightness(1.35); }
.rs-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; padding: 0; list-style: none; color: var(--mp-muted); font-size: .8125rem; }
.rs-key { display: inline-block; width: 14px; height: 14px; margin-right: 4px; vertical-align: -2px; border: 3px solid var(--cp-corner); }
.rs-key.is-cogood { border-style: dashed; }
.rs-key.is-normal { border-width: 2px; border-color: var(--cp-rim-line); }
.rs-sigs { display: grid; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.rs-sig { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); gap: 4px 10px; align-items: center; padding: 8px 10px;
  border-left: 6px solid var(--mp-border); border-radius: var(--mp-radius-sm); background: var(--mp-surface-muted); }
.rs-sig.res-0 { border-left-color: var(--res-0); } .rs-sig.res-1 { border-left-color: var(--res-1); } .rs-sig.res-2 { border-left-color: var(--res-2); }
.rs-sig.res-3 { border-left-color: var(--res-3); } .rs-sig.res-4 { border-left-color: var(--res-4); } .rs-sig.res-5 { border-left-color: var(--res-5); }
.rs-sig.res-6 { border-left-color: var(--res-6); } .rs-sig.res-7 { border-left-color: var(--res-7); }
.rs-res { font-weight: 700; }
.rs-signs { font: 600 1.15rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .15em; }
.rs-signs .is-erased { color: var(--mp-muted); text-decoration: line-through; opacity: .6; }
.rs-info { grid-column: 2; color: var(--mp-muted); font-size: .8125rem; }
.rs-acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.rs-acts .cp-button { min-height: 2.25rem; padding: .3rem .7rem; font-size: .8125rem; }

/* Littlewood–Richardson */
.lr-terms { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.lr-term { display: grid; justify-items: center; gap: 4px; min-height: 44px; padding: 6px 8px; border: 1px solid var(--mp-border); border-radius: var(--mp-radius-sm);
  background: var(--mp-surface); color: var(--mp-ink); font-size: .8125rem; font-variant-numeric: tabular-nums; cursor: pointer; }
.lr-term:hover { border-color: var(--mp-link); }
.lr-term.is-current { border-color: var(--cp-corner); box-shadow: 0 0 0 2px var(--cp-corner); }
.lr-panel { margin-top: 20px; }
.lr-panel h2 { font-size: 1.05rem; }
.lr-tableaux { display: flex; flex-wrap: wrap; gap: 18px; margin: 0; padding: 0; list-style: none; }
.lr-word { margin: 4px 0 0; color: var(--mp-muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.yd .lr-1 rect { fill: var(--res-1); } .yd .lr-2 rect { fill: var(--res-0); } .yd .lr-3 rect { fill: var(--res-2); }
.yd .lr-4 rect { fill: var(--res-3); } .yd .lr-5 rect { fill: var(--res-4); } .yd .lr-6 rect { fill: var(--res-5); }

@media (max-width: 760px) {
  .rsk-stage { grid-template-columns: minmax(0, 1fr); }
  .mn-path { align-items: flex-start; }
}

/* Bruhat order and KL polynomials */
.kl-select { min-height: var(--mp-control-height); padding: .5rem .75rem; border: 1px solid var(--mp-control-border); border-radius: var(--mp-radius);
  background: var(--mp-surface); color: var(--mp-ink); font: 400 1rem var(--mp-sans); }
.kl-legend { font-size: .875rem; font-weight: 700; }
.kl-kind { border: 0; padding: 0; margin: 0; }
.kl-kind legend { margin-bottom: 6px; font-size: .875rem; font-weight: 700; }
.kl-kind .mp-check { font-size: .9375rem; }
.kl-dynkin .kl-bond { stroke: var(--mp-ink); stroke-width: 1.5; }
.kl-dynkin .kl-arrow { fill: none; stroke: var(--mp-ink); stroke-width: 1.5; }
.kl-node { cursor: pointer; }
.kl-node circle { fill: var(--mp-surface); stroke: var(--mp-ink); stroke-width: 1.5; }
.kl-node text { fill: var(--mp-ink); font-size: 11px; font-weight: 600; pointer-events: none; }
.kl-node.is-in circle { fill: var(--mp-product); stroke: var(--mp-product); }
.kl-node.is-in text { fill: #fff; }
.kl-node:focus-visible circle { stroke: var(--mp-focus); stroke-width: 3; }
.kl-stage { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; }
.kl-scroll { overflow: auto; max-height: 72vh; }
.kl-edge { stroke: var(--mp-border-strong); stroke-width: 1; }
.kl-edge.is-in { stroke: var(--cp-rim-line); stroke-width: 2; }
.kl-elt { cursor: pointer; }
.kl-elt circle { fill: var(--mp-surface); stroke: var(--mp-border-strong); stroke-width: 1.5; }
.kl-elt.is-below circle { fill: var(--cp-rim); stroke: var(--cp-rim-line); }
.kl-elt.is-nontrivial circle { fill: var(--cp-corner); stroke: var(--cp-corner); }
.kl-elt.is-nontrivial .kl-label { fill: var(--cp-on-corner); }
.kl-elt.is-top circle { stroke: var(--mp-ink); stroke-width: 3; }
.kl-elt.is-bottom circle { stroke: var(--mp-ink); stroke-width: 3; stroke-dasharray: 3 2; }
.kl-elt:hover circle, .kl-elt:focus-visible circle { stroke: var(--mp-focus); stroke-width: 3; }
.kl-label { fill: var(--mp-ink); font-size: 10px; font-weight: 600; pointer-events: none; font-variant-numeric: tabular-nums; }
.kl-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; padding: 0; list-style: none; color: var(--mp-muted); font-size: .8125rem; }
.kl-dot { display: inline-block; width: 12px; height: 12px; margin-right: 3px; vertical-align: -1px; border-radius: 50%; border: 1.5px solid var(--mp-border-strong); }
.kl-dot.is-top { border: 3px solid var(--mp-ink); }
.kl-dot.is-below { background: var(--cp-rim); border-color: var(--cp-rim-line); }
.kl-dot.is-nontrivial { background: var(--cp-corner); border-color: var(--cp-corner); }
.kl-list { overflow: auto; max-height: 72vh; }
.kl-table { width: 100%; border-collapse: collapse; font-size: .875rem; font-variant-numeric: tabular-nums; }
.kl-table th { position: sticky; top: 0; padding: 6px 8px; background: var(--mp-surface-muted); text-align: left; font-weight: 700; }
.kl-table td { padding: 5px 8px; border-top: 1px solid var(--mp-border); }
.kl-table tr { cursor: pointer; }
.kl-table tbody tr:hover td { background: var(--mp-surface-soft); }
.kl-table tr.is-nontrivial td { color: var(--cp-corner); font-weight: 700; }
.kl-table tr.is-current td { background: var(--cp-rim); }
@media (max-width: 960px) { .kl-stage { grid-template-columns: minmax(0, 1fr); } }

/* Root systems, alcoves, weights; billiards */
.type-0 { --wall: #bb5237; } .type-1 { --wall: #2f8f83; } .type-2 { --wall: #6b5aa6; } .type-3 { --wall: #b08a2c; }
html[data-theme="dark"] .type-0 { --wall: #e8957a; } html[data-theme="dark"] .type-1 { --wall: #6cc5b6; }
html[data-theme="dark"] .type-2 { --wall: #a998e0; } html[data-theme="dark"] .type-3 { --wall: #e0bf68; }
.rt-panel .cp-figure, .bi-stage .cp-figure { overflow: hidden; }
.rt-plane, .bi-table, .bi-unfold { max-width: 100%; height: auto; touch-action: none; }
.rt-chamber { fill: var(--mp-surface-soft); }
.rt-wall { stroke: var(--mp-border-strong); stroke-width: 1; }
.rt-wall0 { stroke: var(--mp-ink); stroke-width: 1.6; opacity: .55; }
.rt-a0 { fill: none; stroke: var(--mp-ink); stroke-width: 2; stroke-dasharray: 5 3; }
.rt-current { fill: var(--cp-rim); stroke: var(--cp-rim-line); stroke-width: 2; }
.rt-neighbour { fill: transparent; cursor: pointer; }
.rt-neighbour:hover { fill: var(--cp-path); }
.rt-plane { cursor: pointer; }
.rt-typed { stroke: var(--wall); stroke-width: 4; stroke-linecap: round; pointer-events: none; }
.rt-walllabel { fill: var(--wall); font-size: 15px; font-weight: 700; pointer-events: none; }
.rt-root { stroke: var(--mp-muted); stroke-width: 1.5; pointer-events: none; }
.rt-root.is-simple { stroke: var(--cp-corner); stroke-width: 2.5; }
.rt-head { fill: var(--mp-muted); }
.rt-label { fill: var(--cp-corner); font-size: 14px; font-weight: 700; font-style: italic; pointer-events: none; }
.rt-orbit { fill: var(--cp-rim); fill-opacity: .45; stroke: var(--cp-rim-line); stroke-width: 1.5; }
.rt-weight circle { fill: var(--mp-ink); }
.rt-weight text { fill: var(--mp-surface); font-size: 11px; font-weight: 700; pointer-events: none; }
.rt-weight.is-highest circle { fill: var(--cp-corner); }
.bi-stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.bi-felt { fill: var(--cp-rim); fill-opacity: .55; }
.bi-cushion { stroke: var(--wall); stroke-width: 5; stroke-linecap: round; }
.bi-path line { stroke: var(--cp-corner); stroke-width: 1.8; }
.bi-ball { fill: var(--mp-ink); stroke: var(--mp-surface); stroke-width: 2; }
.bi-aim { stroke: var(--mp-ink); stroke-width: 2; stroke-dasharray: 4 3; }
.bi-table { cursor: crosshair; }
.bi-start { fill: var(--cp-rim); stroke: var(--cp-rim-line); stroke-width: 2; }
.bi-crossed { fill: var(--cp-path); fill-opacity: .7; }
.bi-ray { stroke: var(--cp-corner); stroke-width: 2.2; }
.bi-sequence { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; font: 600 1rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.bi-letter { display: grid; place-items: center; min-width: 1.9rem; height: 1.9rem; padding: 0 4px; border-bottom: 3px solid var(--wall); border-radius: var(--mp-radius-sm);
  background: var(--mp-surface-muted); color: var(--mp-ink); }
@media (max-width: 960px) { .bi-stage { grid-template-columns: minmax(0, 1fr); } }
.cp-field[hidden] { display: none; }
