/* MusBioMaus page. Builds on style.css variables, so it follows the light/dark theme. */
.mbm-hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: clamp(28px, 5vw, 64px); align-items: center; }
.mbm-title { font-size: clamp(2.2rem, 4.6vw, 3.6rem); line-height: 1.05; letter-spacing: -0.025em; }
.mbm-acr { color: var(--blue, var(--violet)); }
.mbm-hero-fig { margin: 0; border-radius: var(--radius, 20px); overflow: hidden; border: 1px solid var(--line); background: #000; }
.mbm-hero-fig img { display: block; width: 100%; height: auto; }
.mbm-soon { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.mbm-soon span { font-size: .8rem; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 999px; padding: 6px 12px; }

.mbm-paper { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px 40px; align-items: center; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); padding: clamp(22px, 3.5vw, 36px); }
.mbm-paper h2 { font-size: clamp(1.3rem, 2.4vw, 1.8rem); line-height: 1.25; margin: 14px 0 12px; }
.mbm-authors { margin: 0 0 6px; color: var(--text-2); }
.mbm-note { font-size: .85rem; margin: 6px 0 0; }
.mbm-paper-links { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }

.mbm-videos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.mbm-video { margin: 0; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.mbm-video.wide { grid-column: 1 / -1; }
.mbm-video video { display: block; width: 100%; height: auto; background: #000; aspect-ratio: 16 / 9; object-fit: contain; }
.mbm-video.wide video { aspect-ratio: 8 / 3; }
.mbm-video figcaption { padding: 18px 22px 22px; }
.mbm-video h3 { font-size: 1.1rem; margin: 0 0 6px; }
.mbm-video p { margin: 0; color: var(--muted); font-size: .92rem; }

.mbm-strip { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
.mbm-strip .mbm-thumb { flex: 0 0 clamp(240px, 30vw, 360px); scroll-snap-align: start; }
.mbm-thumb { display: block; padding: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #000; cursor: zoom-in; width: 100%; }
.mbm-thumb.light { background: #fff; }
.mbm-thumb:hover, .mbm-thumb:focus-visible { border-color: var(--teal); }
.mbm-thumb img { display: block; width: 100%; height: auto; }
.mbm-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 28px; align-items: start; }
.mbm-h3 { font-size: 1.25rem; margin: 0 0 8px; }
.mbm-stl { margin-top: 14px; background: #fff; }
.mbm-bones { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mbm-bones figure { margin: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; }
.mbm-bones video { display: block; width: 100%; aspect-ratio: 1590 / 1080; object-fit: cover; }
.mbm-bones figcaption { padding: 8px 12px; font-size: .82rem; color: var(--text-2); background: var(--surface); }
.mbm-figure { margin: 0; display: flex; flex-direction: column; gap: 10px; max-width: 980px; }
.mbm-figure figcaption { font-size: .85rem; color: var(--muted); }
.mbm-muscles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.mbm-contact p { margin: 8px 0 14px; }

.mbm-lightbox { border: 0; padding: 0; background: transparent; max-width: 94vw; max-height: 92vh; }
.mbm-lightbox::backdrop { background: rgba(0, 0, 0, .85); }
.mbm-lightbox img { display: block; max-width: 94vw; max-height: 92vh; border-radius: 12px; background: #fff; }
.mbm-close { position: fixed; top: 16px; right: 20px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.6rem; cursor: pointer; }

#paper, #videos, #skeleton, #contact { scroll-margin-top: 84px; }
@media (max-width: 960px) {
  .mbm-hero-grid, .mbm-paper, .mbm-split { grid-template-columns: minmax(0, 1fr); }
  .mbm-videos { grid-template-columns: minmax(0, 1fr); }
  .mbm-muscles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- How the code works (pipeline steps + replay) ---------- */
.mbm-demo { border: 1px solid var(--line); border-radius: 24px; background: var(--surface); padding: clamp(16px, 2.6vw, 28px); display: flex; flex-direction: column; gap: 22px; }
.mbm-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; counter-reset: none; }
.mbm-steps button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: .92rem; cursor: pointer; text-align: left; position: relative; transition: border-color .2s, color .2s, background .2s; }
.mbm-steps button b { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; border: 1px solid var(--line-strong); }
.mbm-steps button:hover { color: var(--text); border-color: var(--line-strong); }
.mbm-steps button[aria-selected="true"] { color: var(--text); border-color: transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--grad) border-box; border: 1px solid transparent; }
.mbm-steps button[aria-selected="true"] b { background: var(--grad); color: #fff; border-color: transparent; }
.mbm-step-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 22px 32px; align-items: start; }
.mbm-step-panel[hidden] { display: none; }
.mbm-step-text h3 { font-size: 1.2rem; margin: 2px 0 8px; }
.mbm-step-text p { margin: 0 0 10px; color: var(--text-2, var(--muted)); font-size: .95rem; }
.mbm-step-text code { font-family: var(--mono); font-size: .85em; }
.mbm-in-replay { display: flex; align-items: center; gap: 8px; font-size: .85rem !important; color: var(--muted) !important; }
.mbm-code { margin: 0; border-radius: 16px; border: 1px solid var(--line); background: #07060c; color: #e8e6f3; padding: 0; overflow: auto; font-size: .8rem; line-height: 1.55; }
.mbm-code .f { display: block; padding: 8px 14px; font-family: var(--mono); font-size: .74rem; color: #a9a5bd; border-bottom: 1px solid rgba(255,255,255,.08); }
.mbm-code code { display: block; padding: 12px 14px 14px; font-family: var(--mono); white-space: pre; }
.mbm-code em { font-style: normal; color: #7f7a99; }
.mbm-code .k { color: #c9a6ff; }
.mbm-code .s { color: #7ee7d9; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.dot.mouse { background: transparent; border: 2px dashed var(--magenta); }
.dot.ik { background: var(--amber); }
.dot.model { background: var(--teal); }
.dot.bone { background: #ede6d6; box-shadow: inset 0 0 0 2px var(--teal); }
.dot.act { background: linear-gradient(90deg, #2c1e6e, var(--violet), var(--teal)); width: 22px; border-radius: 4px; }
.dot.sense { background: linear-gradient(90deg, #50145a, var(--magenta), #ffbef0); width: 22px; border-radius: 4px; }

.mbm-replay { border-bottom: 1px solid var(--line); padding-bottom: 22px; display: flex; flex-direction: column; gap: 14px; }
.mbm-replay-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; align-items: end; }
.mbm-replay-head h3 { font-size: 1.15rem; margin: 0 0 4px; }
.mbm-replay-head p { margin: 0; color: var(--muted); font-size: .88rem; max-width: 60ch; }
.mbm-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.mbm-legend label { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; cursor: pointer; user-select: none; }
.mbm-legend input { position: absolute; opacity: 0; pointer-events: none; }
.mbm-legend label:has(input:checked) { color: var(--text); border-color: var(--line-strong); }
.mbm-legend label:has(input:not(:checked)) .dot { opacity: .3; }
.mbm-legend label:has(input:focus-visible) { outline: 2px solid var(--teal); outline-offset: 2px; }

.mbm-replay-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 14px; }
.mbm-left { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mbm-arm { position: relative; flex: 1; min-height: 400px; border-radius: 18px; border: 1px solid var(--line); background: radial-gradient(120% 90% at 50% 20%, #15122a 0%, #07060c 70%); min-height: 340px; overflow: hidden; }
.mbm-arm canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.mbm-arm canvas[data-bones] { pointer-events: none; cursor: default; }
.mbm-arm canvas:active { cursor: grabbing; }
.mbm-readout { position: absolute; top: 12px; left: 14px; display: flex; gap: 8px; font-size: .78rem; pointer-events: none; }
.mbm-readout span { padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.08); color: #e8e6f3; font-variant-numeric: tabular-nums; }
.mbm-readout .ph-reach { background: rgba(45, 212, 196, .22); }
.mbm-readout .ph-pull { background: rgba(125, 108, 246, .3); }
.mbm-readout .ph-return { background: rgba(226, 60, 224, .25); }
.mbm-err { position: absolute; right: 14px; bottom: 12px; text-align: right; color: #e8e6f3; font-size: .78rem; pointer-events: none; }
.mbm-err b { display: block; font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.mbm-err small { color: #a9a5bd; }

.mbm-raster { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mbm-raster-tabs { display: flex; gap: 6px; }
.mbm-raster-tabs button, .mbm-speed button { font: inherit; font-size: .8rem; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.mbm-raster-tabs button.on, .mbm-speed button.on { color: var(--text); border-color: var(--teal); background: rgba(45, 212, 196, .1); }
.mbm-raster-body { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; flex: 1; min-height: 260px; }
.mbm-groups { margin: 0; padding: 0; display: flex; flex-direction: column; }
.mbm-groups button { font: inherit; background: none; border: 0; border-right: 2px solid var(--line-strong); cursor: pointer; transition: color .2s, border-color .2s; }
.mbm-groups button:hover, .mbm-groups button:focus-visible, .mbm-groups button[aria-pressed="true"] { color: var(--text); border-right-color: var(--teal); outline: none; }
.mbm-groups button { flex: var(--n) 1 0; display: flex; align-items: center; justify-content: flex-end; text-align: right; font-size: .7rem; line-height: 1.15; color: var(--muted); border-right: 2px solid var(--line-strong); padding-right: 8px; min-height: 0; }
.mbm-raster canvas[data-raster] { width: 100%; height: 100%; min-height: 260px; border-radius: 10px; cursor: crosshair; display: block; }
.mbm-top { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .8rem; min-height: 1.6em; }
.mbm-top .lbl { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
.mbm-top .mu { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.mbm-top .mu i { width: 34px; height: 6px; border-radius: 3px; background: var(--line); position: relative; overflow: hidden; }
.mbm-top .mu i::after { content: ""; position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--v)); background: var(--grad); }

.mbm-transport { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.mbm-play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; font-size: 1rem; cursor: pointer; }
.mbm-play:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.mbm-scrub { position: relative; height: 72px; }
.mbm-scrub canvas { position: absolute; left: 0; right: 0; top: 18px; width: 100%; height: 54px; pointer-events: none; }
.mbm-phases { position: absolute; inset: 0; }
.mbm-phases .ph { position: absolute; top: 0; bottom: 0; border-radius: 8px; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; color: var(--text); white-space: nowrap; }
.mbm-phases .ph-return { display: flex; justify-content: flex-end; }
.mbm-phases .ph-reach { background: rgba(45, 212, 196, .14); }
.mbm-phases .ph-pull { background: rgba(125, 108, 246, .2); }
.mbm-phases .ph-return { background: rgba(226, 60, 224, .16); }
.mbm-scrub input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.mbm-scrub:has(input:focus-visible) { outline: 2px solid var(--teal); outline-offset: 4px; border-radius: 8px; }
.mbm-speed { display: flex; flex-direction: column; gap: 4px; }
.mbm-fine { margin: 0; font-size: .78rem; color: var(--muted); }
.mbm-demo:not(.is-ready) .mbm-arm::after { content: "Loading the run…"; position: absolute; inset: 0; display: grid; place-items: center; color: #a9a5bd; font-size: .9rem; }
.mbm-demo.is-error .mbm-arm::after { content: "The replay data could not be loaded."; }
#code { scroll-margin-top: 84px; }

@media (max-width: 960px) {
  .mbm-step-panel, .mbm-replay-grid { grid-template-columns: minmax(0, 1fr); }
  .mbm-steps { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .mbm-steps button { flex-direction: column; gap: 4px; padding: 8px 4px; font-size: .72rem; text-align: center; }
  .mbm-arm { min-height: 300px; }
  .mbm-raster-body { grid-template-columns: 70px minmax(0, 1fr); }
  .mbm-transport { grid-template-columns: auto minmax(0, 1fr); }
  .mbm-speed { grid-column: 1 / -1; flex-direction: row; justify-content: center; }
}
.mbm-rotate { position: absolute; right: 14px; top: 12px; display: flex; gap: 8px; align-items: center; font-size: .76rem; }
.mbm-hint { position: absolute; left: 14px; bottom: 12px; font-size: .76rem; color: #e8e6f3; background: rgba(255,255,255,.1); border-radius: 999px; padding: 4px 10px; pointer-events: none; transition: opacity .4s; }
.mbm-demo.rotated .mbm-hint { opacity: 0; }
.mbm-rotate button { font: inherit; font-size: .76rem; color: #e8e6f3; background: transparent; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.mbm-rotate button:hover { border-color: var(--teal); }

/* ---------- Skeleton: bone explorer + CT viewer ---------- */
.mbm-skel { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.mbm-explorer { position: relative; min-height: 520px; border-radius: 24px; border: 1px solid var(--line); overflow: hidden; background: radial-gradient(110% 80% at 50% 35%, #1a1534 0%, #07060c 72%); }
.mbm-explorer canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.mbm-explorer canvas:active { cursor: grabbing; }
.mbm-explorer:not(.is-ready) .mbm-ex-bottom { opacity: .4; pointer-events: none; }
.mbm-explorer.is-error .mbm-ex-name::after { content: " (3D needs WebGL)"; }
.mbm-ex-top { position: absolute; top: 14px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; pointer-events: none; }
.mbm-ex-name { font-size: 1.05rem; font-weight: 600; color: #fff; text-shadow: 0 1px 12px rgba(0,0,0,.6); }
.mbm-ex-btn { pointer-events: auto; font: inherit; font-size: .76rem; color: #e8e6f3; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.2); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.mbm-ex-btn:hover { border-color: var(--teal); }
.mbm-ex-bottom { position: absolute; left: 14px; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.mbm-ex-chips button, .mbm-ex-slider input { pointer-events: auto; }
.mbm-ex-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mbm-ex-chips button { font: inherit; font-size: .78rem; color: #e8e6f3; background: rgba(7,6,12,.6); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 5px 12px; cursor: pointer; transition: border-color .2s, background .2s; }
.mbm-ex-chips button:hover, .mbm-ex-chips button.on { border-color: var(--teal); background: rgba(45,212,196,.18); }
.mbm-ex-slider { display: flex; align-items: center; gap: 10px; font-size: .74rem; color: #a9a5bd; }
.mbm-ex-slider input { flex: 1; accent-color: var(--teal); }

.mbm-ct { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mbm-ct-main { display: block; padding: 0; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: #000; cursor: zoom-in; }
.mbm-ct-main img { display: block; width: 100%; aspect-ratio: 1400 / 820; object-fit: cover; }
.mbm-ct-bar { display: flex; align-items: center; gap: 12px; font-size: .8rem; color: var(--muted); }
.mbm-ct-bar input { flex: 1; accent-color: var(--violet); }
.mbm-ct-title { color: var(--text); font-weight: 600; }
.mbm-ct-count { font-variant-numeric: tabular-nums; }
.mbm-ct-thumbs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.mbm-ct-thumb { padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #000; cursor: pointer; opacity: .55; transition: opacity .2s, border-color .2s; }
.mbm-ct-thumb:hover, .mbm-ct-thumb.on { opacity: 1; border-color: var(--violet); }
.mbm-ct-thumb img { display: block; width: 100%; aspect-ratio: 1400 / 820; object-fit: cover; }

.mbm-turntables { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.mbm-turntables figure { margin: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.mbm-turntables video { display: block; width: 100%; aspect-ratio: 1590 / 1080; object-fit: cover; }
.mbm-turntables .mbm-stl { border: 0; border-radius: 0; margin: 0; flex: 1; display: grid; place-items: center; }
.mbm-turntables .mbm-stl img { aspect-ratio: 1590 / 1080; object-fit: contain; }
.mbm-turntables figcaption { padding: 8px 12px; font-size: .82rem; color: var(--text-2, var(--muted)); background: var(--surface); }
@media (max-width: 960px) {
  .mbm-skel { grid-template-columns: minmax(0, 1fr); }
  .mbm-explorer { min-height: 420px; }
  .mbm-turntables { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Cite box ---------- */
.mbm-cite { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 14px; }
.mbm-cite summary { cursor: pointer; font-weight: 600; font-size: .95rem; list-style: none; display: inline-flex; align-items: center; gap: 8px; }
.mbm-cite summary::-webkit-details-marker { display: none; }
.mbm-cite summary::before { content: "+"; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); font-weight: 400; transition: transform .2s; }
.mbm-cite[open] summary::before { content: "−"; }
.mbm-cite-body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 12px; }
.mbm-cite pre { margin: 0; width: 100%; overflow-x: auto; font-family: var(--mono); font-size: .78rem; line-height: 1.55; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--text); white-space: pre; }

/* ---------- Replay: linked selection + MuJoCo render ---------- */
.mbm-msel { position: absolute; top: 48px; left: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: rgba(45,212,196,.18); border: 1px solid rgba(45,212,196,.5); color: #e8fffb; font-size: .8rem; }
.mbm-msel[hidden] { display: none; }
.mbm-msel b { font-weight: 600; text-transform: capitalize; }
.mbm-msel button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; line-height: 1; }
.mbm-msel button[hidden] { display: none; }
.mbm-render { margin: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #000; }
.mbm-render video { display: block; width: 100%; aspect-ratio: 16 / 7; object-fit: cover; object-position: 40% 55%; }
.mbm-render figcaption { font-size: .72rem; color: var(--muted); padding: 6px 10px; background: var(--surface); }
.mbm-raster-body { min-height: 220px; }
.mbm-raster canvas[data-raster] { min-height: 220px; }
.mbm-cite .btn { background: transparent; color: var(--text); font-family: inherit; cursor: pointer; }
.dot.mus { background: linear-gradient(90deg, #3e9bfe, #1ecbda, #35f394, #f8be39, #ea4e0d, #a91601); width: 22px; border-radius: 4px; }
details.mbm-fine summary { cursor: pointer; color: var(--muted); font-size: .78rem; width: max-content; }
details.mbm-fine summary:hover { color: var(--text); }
details.mbm-fine p { margin: 6px 0 0; }
