body { margin: 0; }
header { display: flex; align-items: center; gap: .85rem; padding: .6rem 1.2rem; border-bottom: 1px solid var(--border); }
header h1 { font-size: 1.35rem; margin: 0; }
.home { font-size: .8rem; color: var(--muted); text-decoration: none; }
.subtitle { color: var(--muted); font-size: .9rem; }
#theme-toggle { margin-left: auto; }
.toolbar, .panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.intro, .hint { color: var(--muted); font-size: .85rem; }
.intro { margin: .7rem 0; }
.panel-head { min-height: 2.8rem; }
.panel-head h2 { font-size: 1rem; margin: 0 auto 0 0; }
.panel-head label { font-size: .8rem; }
textarea { display: block; width: 100%; box-sizing: border-box; resize: vertical; font: .875rem/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; tab-size: 2; border: 1px solid var(--border); border-radius: .35rem; background: var(--surface); color: var(--text); padding: .8rem; }
#source { height: clamp(280px, 40vh, 420px); margin-bottom: .5rem; }
details { margin-top: .9rem; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: .35rem; }
summary { cursor: pointer; font-weight: 600; }
details p { max-width: 90ch; font-size: .85rem; line-height: 1.5; }
.inputs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: .8rem 0; }
.inputs-grid label { font-size: .85rem; }
.inputs-grid textarea { margin-top: .3rem; }
#sample-index { width: 5rem; }
#error { white-space: pre-wrap; padding: .75rem; border: 1px solid #b74949; border-radius: .35rem; color: #b74949; font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
#warnings { font-size: .85rem; color: var(--muted); white-space: pre-wrap; }
@media (max-width: 700px) {
  header { padding: .55rem .7rem; gap: .6rem; }
  .subtitle { display: none; }
  .panel-head { gap: .35rem; }
  .panel-head label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .panel-head select { max-width: 10rem; }
  #mode { max-width: 100%; }
}
/* Model explorer shares the converter's restrained workspace and native controls. */
[hidden] { display: none !important; }
button[aria-pressed="true"] { border-color: var(--accent, #3c709a); background: var(--accent, #3c709a); color: white; }
.explore-settings { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; font-size: .8rem; }
.explore-settings label { display: flex; align-items: center; gap: .3rem; }
#simulation-seed { width: 6rem; }
#explore-status { color: var(--muted); font-size: .8rem; margin: .6rem 0; }
#explore-stale { color: #99651a; font-size: .85rem; }
#explore-error { color: #bc4141; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85rem; }
.graph-scroll { overflow: auto; border: 1px solid var(--border); border-radius: .35rem; background: var(--surface); }
#model-graph { display: block; width: 100%; min-width: 430px; max-height: 540px; touch-action: pan-y; }
.dependency-edge { fill: none; stroke: var(--muted); stroke-width: 1.4; opacity: .65; }
#dependency-arrow { color: var(--muted); }
.model-node { cursor: pointer; touch-action: none; outline: none; }
.node-shape { fill: var(--surface); stroke: #6384a0; stroke-width: 1.5; }
.node-input .node-shape { fill: color-mix(in srgb, var(--muted) 12%, var(--surface)); stroke: var(--muted); }
.node-observed .node-shape { fill: color-mix(in srgb, #4f9b81 18%, var(--surface)); stroke: #43856f; }
.node-deterministic .node-shape { stroke: #a58249; }
.model-node.selected .node-shape, .model-node:focus .node-shape { stroke-width: 3; }
.model-node:focus .node-shape { stroke-dasharray: 4 2; }
.node-name { fill: var(--text); font: 600 17px ui-monospace, monospace; pointer-events: none; }
.node-caption { fill: var(--muted); font: 11px system-ui; pointer-events: none; }
.plate-outline { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; pointer-events: none; }
.plate-label { fill: var(--muted); font: 10px system-ui; }
.graph-key { display: flex; flex-wrap: wrap; gap: .3rem .8rem; margin: .4rem 0; font-size: .72rem; color: var(--muted); }
.key-stochastic { color: #6384a0; }.key-deterministic { color: #a58249; }.key-observed { color: #43856f; }
.node-equation { width: 100%; font: .8rem ui-monospace, monospace; margin: 0; overflow-wrap: anywhere; }
.fixed-choice { font-size: .8rem; }.fixed-value { width: 6rem; }
.prior-argument { display: flex; align-items: center; gap: .35rem; font-size: .8rem; }
.prior-argument input[type="range"] { width: 90px; }
.prior-argument input[type="number"] { width: 4.4rem; }
.scenario-line { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .75rem; color: var(--muted); margin: .5rem 0; }
.marginals { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .55rem; }
.marginal { min-width: 0; border: 1px solid var(--border); border-radius: .35rem; padding: .4rem .5rem; }
.marginal-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.marginal-head button { padding: .1rem .25rem; font: 600 .85rem ui-monospace, monospace; border: none; background: transparent; color: var(--text); }
.marginal-head select { font-size: .75rem; padding: .1rem .2rem; }
.marginal svg { display: block; width: 100%; }
.marginal p { margin: 0; font-size: .7rem; color: var(--muted); }
.hist-bar { fill: #6384a0; }.node-observed .hist-bar { fill: #4f947e; }.node-deterministic .hist-bar { fill: #a58249; }
.hist-axis { stroke: var(--border); }.hist-count,.hist-tick { fill: var(--muted); font: 11px system-ui; }
.is-stale { opacity: .45; }
.export-panel .toolbar { margin: .7rem 0; }
@media (max-width: 950px) {
  #model-graph { max-height: none; }
}
@media (max-width: 480px) {
  .marginals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .explore-settings { gap: .45rem; }
  .prior-argument { flex-wrap: wrap; }
}
#model-graph { touch-action: none; }
.hist-reference { stroke: var(--muted); stroke-width: 1.2; fill: none; stroke-linejoin: round; }
.reference-mark { display: inline-block; width: 1.3em; height: .6em; margin-right: .25em; border: 1px solid var(--muted); vertical-align: middle; }
.graph-scroll { max-height: 500px; }
#model-graph { max-height: none; }
@media (max-width: 700px) { .graph-scroll { max-height: 440px; } }
.marginal.selected { border-color: #6384a0; box-shadow: inset 0 0 0 1px #6384a0; }

/* Mathematical specification and linked equations. */
#model-spec { border: 1px solid var(--border); border-radius: .35rem; background: var(--surface); overflow: auto; padding: .5rem; }
.spec-hint { margin-top: 0; }
.model-equation { display: flex; align-items: center; gap: .8rem; width: 100%; min-width: 0; padding: .7rem .45rem; text-align: left; background: transparent; border: 1px solid transparent; color: var(--text); border-radius: .25rem; }
.model-equation + .model-equation { margin-top: .15rem; }
.model-equation.selected { background: color-mix(in srgb, #6384a0 12%, var(--surface)); color: var(--text); border-color: #6384a0; }
.equation-line { flex: none; color: var(--muted); font: .7rem ui-monospace, monospace; width: 2.8em; border: 0; background: transparent; padding: .4rem .1rem; cursor: pointer; }
.equation-math { display: block; min-width: 0; overflow-x: auto; padding: .2rem; font-size: 1.15rem; }
.equation-math math { margin: 0; }
#normalized-source { overflow: auto; max-height: 280px; font-size: .8rem; }
#export-scope { margin-bottom: .3rem; }
#status { color: var(--muted); font-size: .8rem; }
#explore-output { min-height: 240px; }
#syntax-status { overflow-wrap: anywhere; }
@media (max-width: 480px) { header h1 { font-size: 1.15rem; } #explore-format { max-width: 100%; } .equation-math { font-size: 1rem; } }


.equation-line[aria-pressed="true"] { background: transparent; color: var(--text); }
.model-equation { box-sizing: border-box; cursor: pointer; }

.graph-scroll { cursor: grab; touch-action: none; }
.graph-scroll.is-panning, .graph-scroll.is-panning *, .graph-scroll.is-dragging-node, .graph-scroll.is-dragging-node * { cursor: grabbing; }
