/* Causal motion belongs to the mechanism timeline, never to page furniture. */
.mechanism-diagram { --tone:var(--beat-tone,var(--purple,#0969bd));--sea:#8fcde3;--sea-line:#2f86ad;--net:#2273bd;--write:#9a6a12;--fail:#b4492f;--done:#23805f;--hold:#94680f;overflow:visible; }
[data-theme=dark] .mechanism-diagram { --sea:#2c6f92;--sea-line:#8fd3ef;--net:#8cc4ff;--write:#e5ba68;--fail:#f0a58f;--done:#86d9b6;--hold:#e5ba68; }
/* The stage takes the size the player computed from the laid-out nodes, so rows are never cut by a fixed box. */
.embedded-mechanism .mechanism-viewport .lecture-stage,#main .beat-mechanism .mechanism-viewport .lecture-stage { height:auto!important;min-height:0;aspect-ratio:auto;padding:0;display:block; }
.mechanism-viewport .mechanism-diagram,#main .beat-mechanism .mechanism-viewport .mechanism-diagram { display:block;width:var(--diagram-width,100%)!important;height:var(--diagram-height,auto)!important;min-height:0;max-height:none;margin:0 auto; }
#main .beat-mechanism .lecture-visual .mechanism-viewport { height:auto;max-height:none;padding:4px 0; }
/* The card owns its tint: no wash leaks past it, it sits above the decorative crew, and its wash keeps the play control above 4.5:1. */
#main .beat-mechanism .embedded-flow>.lecture-visual { position:relative;z-index:1;background:color-mix(in srgb,var(--bg) 92%,#37788a 8%); }
#main .beat-mechanism .lecture-visual::before { content:none; }

/* Nodes are port objects. Selectors carry `.mechanism-diagram g` so the older dev-tools box rules for node rects, circles and text no longer reach them. */
.mechanism-node { --tone:var(--beat-tone,var(--purple,#0969bd));animation:none;transition:opacity .18s; }
.mechanism-node.active { --tone:var(--net); }
.mechanism-node.ready { --tone:var(--done); }
.mechanism-node.error { --tone:var(--fail); }
.mechanism-node.waiting,.mechanism-node.blocked { --tone:var(--hold); }
.mechanism-diagram g.mechanism-node.gone,#main .beat-mechanism .mechanism-diagram g.mechanism-node.gone { opacity:.38; }
.mechanism-diagram g.mechanism-node .node-tile { fill:color-mix(in srgb,var(--tone) 7%,var(--paper));stroke:color-mix(in srgb,var(--tone) 30%,var(--paper));stroke-width:1.5; }
.mechanism-diagram g.mechanism-node.participant .node-tile { fill:color-mix(in srgb,var(--tone) 15%,var(--paper));stroke:var(--tone);stroke-width:2.5; }
.mechanism-diagram g.mechanism-node .node-title { font-family:var(--body);font-weight:650;fill:var(--ink); }
.mechanism-diagram g.mechanism-node .node-title.code { font-family:var(--mono);font-weight:500; }
.mechanism-diagram g.mechanism-node .node-sub { font-family:var(--mono);font-weight:400;fill:var(--muted); }
.mechanism-diagram g.mechanism-node .node-state { font-family:var(--body);font-weight:700;fill:var(--ink);paint-order:stroke;stroke:var(--bg);stroke-width:4px;stroke-linejoin:round; }
.mechanism-diagram g.mechanism-node.gone .node-title { text-decoration:line-through; }
/* Only the parts this event touches speak; the rest keep their name and stay quiet. */
.mechanism-diagram g.mechanism-node:not(.participant) .node-sub { visibility:hidden;opacity:0; }
.mechanism-diagram g.mechanism-node:not(.participant) .node-title { transform:translateY(var(--quiet-drop,0px)); }
.mechanism-diagram g.mechanism-node :is(.node-title,.node-sub,.port-glyph) { transition:transform .22s cubic-bezier(.2,.7,.2,1),opacity .22s; }
.mechanism-diagram g.mechanism-node [data-fit=none] { display:none; }
.mechanism-diagram.measuring g.mechanism-node :is(.node-title,.node-sub) { display:inline!important;visibility:visible;transform:none; }
.mechanism-diagram g.mechanism-node .port-glyph :is(.f,.t,.s,.w,.eye) { stroke:none; }
.mechanism-diagram g.mechanism-node .port-glyph .f { fill:color-mix(in srgb,var(--tone) 70%,var(--paper)); }
.mechanism-diagram g.mechanism-node .port-glyph .t { fill:color-mix(in srgb,var(--tone) 30%,var(--paper)); }
.mechanism-diagram g.mechanism-node .port-glyph .s { fill:color-mix(in srgb,var(--tone) 72%,#0b1726); }
.mechanism-diagram g.mechanism-node .port-glyph .w { fill:var(--sea); }
.mechanism-diagram g.mechanism-node .port-glyph .eye { fill:#0b1726; }
.mechanism-diagram g.mechanism-node .port-glyph .l { fill:none;stroke:color-mix(in srgb,var(--tone) 78%,var(--ink));stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round; }
.mechanism-diagram g.mechanism-node .port-glyph .thin { stroke-width:1.6; }
.mechanism-diagram g.mechanism-node .port-glyph .water { stroke:var(--sea-line);stroke-width:1.8; }
.mechanism-diagram g.mechanism-node .port-glyph .rope { stroke:color-mix(in srgb,var(--hold) 80%,var(--ink));stroke-width:2; }
.mechanism-diagram g.mechanism-node .port-glyph .ribs { stroke:var(--paper);stroke-width:1.2;opacity:.55; }
.mechanism-diagram g.mechanism-node:not(.participant) .port-glyph { opacity:.72; }
.mechanism-diagram g.mechanism-node.participant .port-glyph { transform:translateY(-3px); }
[data-theme=dark] .mechanism-diagram g.mechanism-node.participant .port-glyph { filter:drop-shadow(0 0 6px color-mix(in srgb,var(--tone) 80%,transparent)); }
[data-theme=dark] .mechanism-diagram g.mechanism-node.participant .node-tile { filter:drop-shadow(0 0 8px color-mix(in srgb,var(--tone) 45%,transparent)); }

.mechanism-diagram path.mechanism-wire { fill:none;stroke:var(--muted);stroke-width:1.5;opacity:.38;transition:opacity .2s; }
.mechanism-diagram path.mechanism-wire.engaged { opacity:1;stroke:var(--tone);stroke-width:2.5; }
.mechanism-diagram path.mechanism-wire.network.engaged { stroke:var(--net); }
.mechanism-diagram path.mechanism-wire.write.engaged { stroke:var(--write); }
.mechanism-arrow { fill:none;stroke:var(--muted);stroke-width:1.5; }
.mechanism-arrow.network { stroke:var(--net); }
.mechanism-arrow.write { stroke:var(--write); }
.mechanism-arrow.control,.mechanism-arrow.read { stroke:var(--tone); }
.mechanism-diagram g.mechanism-packet { fill:var(--tone);pointer-events:none; }
.mechanism-diagram g.mechanism-packet.network { fill:var(--net); }
.mechanism-diagram g.mechanism-packet.write { fill:var(--write); }
.mechanism-packet .packet-halo { opacity:.22; }
.mechanism-zone rect,#main .beat-mechanism .mechanism-zone rect { fill:color-mix(in srgb,var(--sea) 14%,transparent);stroke:color-mix(in srgb,var(--sea-line) 45%,transparent);stroke-width:1.2;stroke-dasharray:5 6; }
.mechanism-zone text,#main .beat-mechanism .mechanism-zone text { font-family:var(--mono);fill:var(--muted); }

.mechanism-event { position:relative;padding:8px 20px 0;min-height:57px;flex:none; }
.mechanism-event-line { display:flex;gap:9px;align-items:center; }
.mechanism-event-index { font:10px var(--mono);color:#9dd7c7;flex:none; }
.mechanism-event strong { font:600 12px/1.4 var(--body);color:#e0efe9;flex:1;min-width:0; }
.mechanism-event code { display:block;margin:5px 0 0 24px;font:10px/1.5 var(--mono);color:#adc3d0;overflow-wrap:anywhere; }
.mechanism-event select { width:auto;max-width:135px;min-width:0;font:10px var(--body);padding:7px;background:#223f4e;color:#e0eee9;border:1px solid #5a7782;border-radius:6px; }
.mechanism-scrub { display:flex;align-items:center;gap:14px;padding:5px 20px;min-height:29px;position:relative;flex:none; }
.mechanism-scrub input { width:100%;min-width:0;accent-color:#a7e9d6;height:16px;cursor:pointer; }
.mechanism-scrub span { font:9px var(--mono);color:#b0c5cd;white-space:nowrap; }
.lecture-transport { padding-top:6px;gap:10px;flex-wrap:nowrap; }
.lecture-transport [data-mechanism-next] { min-width:44px;width:44px;height:44px;padding:0;display:grid;place-items:center;background:#203f4c;color:#d0e3e8;border-color:#59737f; }
.lecture-transport .button { min-height:44px; }
.lecture-mode { flex:1;min-width:0; }
.mechanism-trace h3 { font-size:15px;margin:24px 0 12px; }
.mechanism-trace ol { padding-left:24px; }
.mechanism-trace li { padding:10px 0;font-size:13px;line-height:1.65; }
.mechanism-trace li p,.mechanism-trace > p { color:var(--muted);font-size:13px;line-height:1.7;margin:5px 0; }
.mechanism-trace code { display:block;font:11px/1.7 var(--mono);overflow-wrap:anywhere;background:var(--surface-soft);padding:9px 12px;border-radius:6px;margin:8px 0; }
.mechanism-trace ul { padding-left:20px; }
.mechanism-trace ul .source-link { overflow-wrap:anywhere; }
@media(max-width:720px){
 .mechanism-event { padding:5px 12px 0;min-height:35px; }
 .mechanism-event strong { font-size:10px; }
 .mechanism-event-line { gap:6px; }
 .mechanism-event select { font-size:9px;max-width:112px;padding:6px 4px; }
 .mechanism-event code { display:none; }
 .mechanism-scrub { padding:3px 12px;min-height:25px;gap:9px; }
 .lecture-visual { min-height:218px; }
 .lecture-transport { padding:3px 12px 7px;gap:8px; }
 .lecture-transport .lecture-mode { font-size:7.5px; }
 .lecture-transport .button { font-size:9px; }
 .lecture-narration h2 { font-size:19px; }
 .lecture-explanation-open { font-size:10px; }
}
@media(max-height:610px){ .lecture-visual { height:360px; }.mechanism-event code{display:block;} }
/* A landscape phone gives the event line the left column and the diagram the right; neither may spill into the other. */
@media(max-height:499px) and (min-width:700px){
 #main[data-beat-type=mechanism] .beat-mechanism .lecture-visual { grid-template-columns:minmax(0,1fr) minmax(0,1.5fr);grid-template-rows:minmax(0,auto) 44px;align-items:start;height:auto; }
 #main[data-beat-type=mechanism] .beat-mechanism .mechanism-event { overflow:hidden; }
 #main[data-beat-type=mechanism] .beat-mechanism .lecture-visual .mechanism-viewport { height:auto;align-self:center;margin:0; }
}
@media(prefers-reduced-motion:reduce){.mechanism-node,.mechanism-node *,.mechanism-wire{transition:none!important;}}
html[data-motion=off] :is(.mechanism-node,.mechanism-node *,.mechanism-wire){transition:none!important;}

.lecture-scene-number {margin-left:5px;}
.lecture-transport {padding-bottom:8px;}
.mechanism-scrub input {appearance:none;background:transparent;height:20px;}
.mechanism-scrub input::-webkit-slider-runnable-track {height:3px;border-radius:2px;background:#536e7b;}
.mechanism-scrub input::-webkit-slider-thumb {appearance:none;width:14px;height:14px;border-radius:50%;background:#adedd6;border:2px solid #d8ffeb;margin-top:-5px;}
.mechanism-scrub input::-moz-range-track {height:3px;background:#536e7b;}
.mechanism-scrub input::-moz-range-thumb {width:12px;height:12px;border-radius:50%;background:#adedd6;border:2px solid #d8ffeb;}
