/* ==========================================================
   kianshah.in - /research/ and /projects/constp/ (the solver
   walkthrough). Loaded after style.css and mobile.css on those two
   pages only.
   ========================================================== */

/* ------------------ the paper card ------------------ */
/* the site's own .card / .paper-card box; the identity gets a tinted band
   running edge to edge inside it (--pad-x mirrors the card's side padding) */
.paper-card { --pad-x: clamp(24px, 4.5vw, 40px); }
.paper h3 { line-height: 1.3; margin-bottom: 10px; }
.paper .authors { margin-bottom: 18px; }
.paper > p { max-width: none; }

.eq-lead { color: var(--muted); font-size: 0.86em; margin-top: 4px; margin-bottom: 18px; }
.eq-lead .katex-display { margin: 0.6em 0; }
.eq-narrow { display: none; }       /* stacked versions, shown only on narrow screens */

.eq-hero {
  margin: 26px calc(-1 * var(--pad-x)) 30px;
  padding: clamp(20px, 3.5vw, 34px) var(--pad-x);
  background: rgba(10, 147, 150, 0.06);
  border-block: 1px solid rgba(148, 210, 189, 0.12);
}
.eq-hero .katex-display { font-size: clamp(1.02rem, 2.3vw, 1.42rem); margin: 0 auto; }
.eq-hero .katex { color: #f2ede0; }

.paper .btn-row { margin-top: 26px; }

/* ------------------ values table ------------------ */
.values-table { font-variant-numeric: tabular-nums; }
.values-table th.col-d, .values-table td.col-d { text-align: right; }
.values-table td.col-d { font-size: 14px; color: var(--wheat); }
.values-table td.col-log { white-space: nowrap; }
.values-table td.col-v { word-break: normal; }
.v-mant sup { font-size: 0.72em; }
details.v-digits { margin-top: 4px; }
details.v-digits summary { cursor: pointer; color: var(--aqua); font-size: 11.5px; }
details.v-digits[open] summary { color: var(--amber); }
.v-num {
  margin: 8px 0 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text);
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.v-copy {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  background: none; border: 1px solid var(--line); border-radius: 3px;
  padding: 4px 10px; min-height: 30px; cursor: pointer;
}
.v-copy:hover { color: var(--aqua); border-color: var(--aqua); }

/* ------------------ results as a definition list ------------------ */
dl.results { max-width: 72ch; margin: 0; }
dl.results dt {
  font-weight: 600;
  color: #eee9da;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
dl.results dt:first-child { border-top: 0; padding-top: 0; }
dl.results dd { margin: 4px 0 18px; }
dl.results dd p { margin-bottom: 10px; }
dl.results .katex-display { margin: 0.5em 0; }
.results-close { margin-top: 36px; max-width: 68ch; }

/* ------------------ instruments (the only framed things) ------------------ */
.instrument {
  position: relative;
  border: 1px solid var(--line);
  background: rgba(4, 32, 42, 0.35);
  padding: clamp(14px, 3vw, 26px);
  margin-top: 26px;
}
.instrument-caption { margin-top: 12px; font-size: 15px; color: var(--muted); max-width: 70ch; }

/* ------------------ simulation ------------------ */
.sim-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.sim-tabs button {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.08em;
  color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px; min-height: 44px; cursor: pointer;
}
.sim-tabs button[aria-selected="true"] { color: var(--wheat); border-bottom-color: var(--teal); }

.sim-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button {
  font-family: var(--mono); font-size: 13px; color: var(--muted); background: none;
  border: 0; border-left: 1px solid var(--line); min-width: 40px; min-height: 40px; cursor: pointer;
}
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: rgba(10, 147, 150, 0.22); color: var(--wheat); }
.seg-label { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.sim-controls .btn { min-height: 40px; padding: 6px 14px; font-size: 13px; }
.sim-controls label { font-family: var(--mono); font-size: 12px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.sim-controls input[type="range"] { width: 90px; accent-color: var(--teal); }

.sim-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; }
/* code rows never wrap; if a row is wider than the box, the box scrolls and the
   highlight still covers the full row */
.sim-code {
  margin: 0; padding: 12px 0; background: var(--panel); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; line-height: 1.65; color: var(--muted);
  overflow-x: auto; display: grid; grid-template-columns: minmax(max-content, 1fr); align-content: start;
}
.sim-code span { display: block; padding: 0 8px 0 12px; white-space: pre; border-left: 2px solid transparent; }
.sim-code span.on { color: var(--wheat); background: rgba(10, 147, 150, 0.16); border-left-color: var(--teal); }

.sim-state { display: grid; gap: 14px; align-content: start; min-width: 0; }
.sim-k { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.slots { display: flex; flex-wrap: wrap; gap: 5px; }
.slot {
  display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 4px;
  font-family: var(--mono); font-size: 13px; border: 1px solid var(--line); color: var(--muted);
}
.slot.filled { background: rgba(10, 147, 150, 0.2); border-color: rgba(10, 147, 150, 0.6); color: #eef3f3; }
.slot.cand { border-color: var(--wheat); color: var(--wheat); }
.slot.locked { color: var(--wheat); }
.pool { margin-top: 6px; }
.pool .slot { height: 24px; min-width: 24px; font-size: 11.5px; }
.pool .slot.gone { opacity: 0.18; }

/* every slot in the state panel is a fixed single line, so the panel keeps its
   height however fast the recursion runs */
.sim-line {
  font-family: var(--mono); font-size: 13px; color: var(--text);
  line-height: 1.7; height: 1.7em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pruned-note { font-size: 12px; color: #ffb4a8; }
.badge { display: inline-block; padding: 0 7px; border-radius: 3px; font-size: 12px; line-height: 1.5; margin-left: 6px; }
.badge.pass { background: rgba(10, 147, 150, 0.25); color: #bfe9dd; }
.badge.fail { background: rgba(174, 32, 18, 0.28); color: #ffb4a8; }

.ledger {
  font-family: var(--mono); font-size: 12px; color: var(--muted); height: 150px; overflow-y: auto;
  border-top: 1px solid var(--line); padding-top: 6px; font-variant-numeric: tabular-nums;
}
.ledger div { display: flex; justify-content: space-between; gap: 10px; line-height: 1.6; }
.ledger .plus { color: #bfe9dd; }
.ledger .minus { color: #ffb4a8; }
.ledger .empty { color: rgba(143, 160, 166, 0.6); }
.progress { height: 4px; background: var(--line); margin-top: 8px; }
.progress i { display: block; height: 100%; width: 0; background: var(--teal); }

.counters {
  display: grid; gap: 2px; margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--line); font-family: var(--mono); font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cnt { line-height: 1.7; height: 1.7em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cnt-sum { height: 3.4em; white-space: normal; overflow-wrap: anywhere; }
.counters b { color: var(--text); font-weight: 500; }

.result { margin-top: 14px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); min-height: 10.5em; }
.result-wait { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.result-line { font-family: var(--mono); font-size: 13px; color: var(--text); overflow-wrap: anywhere; line-height: 1.8; }
.result-line b { color: var(--wheat); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-family: var(--mono); font-size: 11.5px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.chip.hot { border-color: #C2862A; color: #e8c07a; }
.sim-controls .run-btn { min-width: 6.5em; justify-content: center; }

.kbd-legend { margin-top: 12px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 3px; color: var(--text); }
@media (hover: none) { .kbd-legend { display: none; } }

/* ------------------ modular method tab ------------------ */
.mod-intro { font-size: 15px; color: var(--text); max-width: 74ch; margin-bottom: 12px; }
.mod-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 18px; }
.mod-section { padding-top: 16px; margin-top: 18px; border-top: 1px solid var(--line); }
.mod-grid .mod-section { padding-top: 0; margin-top: 0; border-top: 0; }
.mod-section h4 { font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--wheat); font-weight: 500; margin-bottom: 8px; }
.mod-section p { font-size: 15px; margin-bottom: 10px; max-width: 74ch; }
.mod-section p.mod-note { font-size: 14px; color: var(--muted); }
.sim-code .mq { font-style: normal; color: var(--wheat); }
.qchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.qchip { font-family: var(--mono); font-size: 12px; padding: 3px 9px; border: 1px solid var(--line); color: var(--muted); border-radius: 3px; }
.qchip.lit { border-color: var(--teal); color: #bfe9dd; }
.table-scroll { max-height: 260px; overflow: auto; border: 1px solid var(--line); margin: 8px 0 10px; }
.mod-table { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.mod-table th {
  position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 500;
  text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.mod-table td { text-align: right; padding: 4px 10px; border-bottom: 1px solid rgba(20, 51, 61, 0.6); color: var(--text); white-space: nowrap; }
.mod-value { font-family: var(--mono); font-size: 13px; color: var(--text); overflow-wrap: anywhere; margin: 2px 0 12px; }
.mod-table .l { text-align: left; }
.mod-table tr.more td { color: var(--muted); }
.mod-table tr.hit td { color: var(--wheat); }
.mod-table tr.stable td { color: var(--muted); }
.mod-steps { font-family: var(--mono); font-size: 13px; line-height: 1.8; color: var(--text); overflow-wrap: anywhere; }
.crt-value { font-family: var(--mono); font-size: 13px; color: var(--text); overflow-wrap: anywhere; margin-top: 8px; }
.match { color: #bfe9dd; }

/* ------------------ subsets (part 1 of the second tab) ------------------ */
.mod-part {
  display: flex; align-items: center; gap: 12px; margin: 30px 0 4px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.mod-part::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.ss-hl { color: #f2ede0; font-weight: 500; white-space: nowrap; }
.ss-eq { overflow-x: auto; overflow-y: hidden; margin: 2px 0 10px; }
.ss-eq .katex-display { margin: 0.4em 0; }
.ss-graphs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin: 14px 0 6px; }
.ss-graphs.wide { grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr); }
.ss-panel { border: 1px solid var(--line); background: var(--panel); padding: 10px; min-width: 0; }
.ss-panel-title { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.ss-scroll { overflow-x: auto; }
.ss-svg { display: block; width: 100%; height: auto; }
.ss-svg:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.ss-small { font-size: 13.5px; color: var(--muted); margin-top: 8px; }
.ss-mod .ss-small, .mod-section .ss-small { font-size: 13.5px; }
.ss-bignums { display: grid; gap: 6px; margin: 10px 0 6px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ss-big { display: inline-block; min-width: 5.5em; font-size: 22px; color: var(--wheat); font-variant-numeric: tabular-nums; }

.ss-edge { stroke: rgba(148, 210, 189, 0.22); stroke-width: 1; }
.ss-edge.hot { stroke: var(--wheat); stroke-width: 1.6; }
.ss-node, .t-node { cursor: pointer; }
.ss-node .shape, .t-node .shape { fill: #0c2630; stroke: rgba(148, 210, 189, 0.45); stroke-width: 1; transition: opacity 0.2s; }
.ss-node .hit, .t-node .hit { fill: transparent; }
.ss-node text, .t-node text {
  fill: var(--text); font-family: var(--mono); font-size: 11px; text-anchor: middle;
  dominant-baseline: central; pointer-events: none;
}
.ss-node text.sub { font-size: 9.5px; fill: var(--muted); }
.ss-node.is-cur .shape { stroke: var(--wheat); stroke-width: 2.2; }
.ss-node.is-sel .shape { stroke: #f2ede0; stroke-width: 2.2; }
.ss-dag.sweep .ss-node .shape { opacity: 0.4; }
.ss-dag.sweep .ss-node.is-stored .shape { opacity: 1; fill: rgba(10, 147, 150, 0.55); stroke: #0a9396; }
.ss-dag.sweep .ss-node.is-gone .shape { opacity: 0.16; }
.ss-dag.sweep .ss-node.is-final .shape { opacity: 1; fill: rgba(194, 134, 42, 0.3); stroke: #C2862A; stroke-width: 2.2; }
.ss-dag.sweep .ss-node.is-cur .shape, .ss-dag.sweep .ss-node.is-sel .shape { opacity: 1; }
.t-edge { stroke: rgba(148, 210, 189, 0.2); stroke-width: 1; }
.t-node.t-seen .shape { fill: rgba(10, 147, 150, 0.6); stroke: #0a9396; }
.t-node.t-rep .shape { fill: rgba(194, 134, 42, 0.55); stroke: #C2862A; }
.t-node.is-mark .shape { stroke: #f2ede0; stroke-width: 2.2; }

.ss-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 10px 0 6px; }
.ss-controls .btn { min-height: 40px; padding: 6px 14px; font-size: 13px; }
.ss-status { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ss-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.ss-legend i { display: inline-block; width: 11px; height: 11px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }
.ss-legend .lg-first { background: rgba(10, 147, 150, 0.6); border: 1px solid #0a9396; }
.ss-legend .lg-rep { background: rgba(194, 134, 42, 0.55); border: 1px solid #C2862A; }
.ss-legend .lg-heat { width: 34px; background: linear-gradient(90deg, oklch(0.30 0.04 195), oklch(0.82 0.13 195)); }
.ss-legend .lg-stored { background: rgba(10, 147, 150, 0.55); border: 1px solid #0a9396; }
.ss-legend .lg-sel { border: 2px solid #f2ede0; }
.ss-info {
  margin-top: 12px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.75; color: var(--text);
  min-height: 9.5em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
}
.ss-info b { color: var(--wheat); font-weight: 500; }
.ss-muted { color: var(--muted); }
.mod-table tr.cur td { color: var(--wheat); background: rgba(10, 147, 150, 0.1); }
.ss-table { max-height: none; }

.ss-bits-demo { border: 1px solid var(--line); background: var(--panel); padding: 12px 14px; margin: 12px 0; }
.ss-row-k { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 12px 0 5px; }
.ss-row-k:first-child { margin-top: 0; }
.ss-key { font-family: var(--mono); font-size: 12.5px; color: var(--text); overflow-wrap: anywhere; line-height: 1.7; }
.ss-bitrow { display: flex; flex-wrap: wrap; gap: 5px; perspective: 400px; }
.ss-bit { display: grid; justify-items: center; gap: 2px; }
.ss-bit small { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.ss-bit b {
  display: grid; place-items: center; width: 32px; height: 32px; font-family: var(--mono); font-size: 14px;
  font-weight: 500; color: var(--muted); border: 1px solid var(--line); transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.ss-bit.on b { background: rgba(10, 147, 150, 0.3); border-color: rgba(10, 147, 150, 0.85); color: #eef3f3; }
.ss-bit.flip b { animation: ss-flip 0.5s ease; }
@keyframes ss-flip {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(90deg); border-color: var(--wheat); }
  100% { transform: rotateX(0); }
}
.ss-sq { display: flex; flex-wrap: wrap; gap: 2px; margin: 4px 0 2px; }
.ss-sq i { display: block; width: 8px; height: 8px; background: rgba(148, 210, 189, 0.12); }
.ss-sq i.one { background: #0a9396; }
.ss-sq.res i { width: 14px; height: 14px; }
.ss-save {
  margin: 18px 0 4px; padding-top: 12px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--wheat);
}
.ss-save:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.ss-live { display: grid; gap: 6px; margin: 4px 0 4px; }
.ss-live-row { display: grid; grid-template-columns: 9.5em minmax(0, 1fr) 7em; gap: 10px; align-items: center; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ss-live .ss-bar i.k { min-width: 2px; transition: width 0.35s ease; }
@media (prefers-reduced-motion: reduce) { .ss-live .ss-bar i.k { transition: none; } }
.ss-bars { display: grid; gap: 8px; margin: 12px 0 8px; }
.ss-bar-row { display: grid; grid-template-columns: 15em minmax(0, 1fr) 9em; gap: 12px; align-items: center; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ss-bar { display: flex; height: 14px; background: rgba(148, 210, 189, 0.06); }
.ss-bar i { display: block; height: 100%; }
.ss-bar i.k { background: #0a9396; }
.ss-bar i.v { background: rgba(10, 147, 150, 0.45); }
.ss-bar-num { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 768px) {
  .ss-graphs, .ss-graphs.wide { grid-template-columns: 1fr; }
  .ss-bar-row { grid-template-columns: minmax(0, 1fr) auto; }
  .ss-bar-row .ss-bar { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) {
  .ss-bit.flip b { animation: none; }
  .ss-node .shape, .t-node .shape, .ss-bit b { transition: none; }
}

.sim-fallback table { border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; margin: 10px 0 18px; font-variant-numeric: tabular-nums; }
.sim-fallback th, .sim-fallback td { padding: 5px 14px 5px 0; border-bottom: 1px solid var(--line); text-align: left; }
.js-ready .sim-fallback { display: none; }

/* ------------------ prime heatmap ------------------ */
.pm-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.pm-toggle button { font-family: var(--mono); font-size: 12px; color: var(--muted); background: none; border: 0; padding: 8px 12px; min-height: 38px; cursor: pointer; }
.pm-toggle button + button { border-left: 1px solid var(--line); }
.pm-toggle button[aria-pressed="true"] { background: rgba(10, 147, 150, 0.22); color: var(--wheat); }
.pm-scroll { overflow-x: auto; padding: 4px 2px 6px; }
.pm-grid { display: grid; gap: 3px; min-width: 520px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pm-row { display: contents; }
.pm-h { display: grid; place-items: center; font-size: 11px; color: var(--muted); height: 26px; }
.pm-q { justify-items: end; padding-right: 6px; }
.pm-corner { font-size: 9.5px; letter-spacing: 0.04em; }
.pm-c {
  display: grid; place-items: center; height: 28px; font-size: 12px; border-radius: 2px;
  color: var(--muted); cursor: default; outline: none;
}
.pm-c.zero { color: rgba(143, 160, 166, 0.45); }
.pm-c.diag { box-shadow: inset 0 0 0 2px #C2862A; }
.pm-c:focus-visible { box-shadow: inset 0 0 0 2px var(--amber), 0 0 0 1px var(--amber); }
.pm-tip {
  position: absolute; z-index: 5; display: none; pointer-events: none; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  padding: 6px 10px; font-family: var(--mono); font-size: 12px; color: var(--text);
}
.pm-tip.shown { display: block; }
#primes-map { position: relative; }
.pm-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px; font-family: var(--mono); font-size: 12px; color: var(--muted); align-items: center; }
.pm-legend .ramp { display: inline-block; width: 90px; height: 10px; border-radius: 2px; vertical-align: middle; margin: 0 6px;
  background: linear-gradient(90deg, oklch(0.30 0.04 195), oklch(0.82 0.13 195)); }
.pm-legend .sq { display: inline-block; width: 13px; height: 13px; border: 2px solid #C2862A; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
details.map-table { margin-top: 14px; }
details.map-table summary { font-family: var(--mono); font-size: 12.5px; color: var(--aqua); cursor: pointer; padding: 6px 0; }
details.map-table[open] summary { color: var(--amber); }
.map-table table { border-collapse: collapse; font-family: var(--mono); font-size: 12px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.map-table th, .map-table td { padding: 3px 7px; text-align: right; border-bottom: 1px solid var(--line); }
.map-table-scroll { overflow-x: auto; }

/* ------------------ code ------------------ */
pre.tree {
  background: var(--panel); border: 1px solid var(--line); padding: 16px 18px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: var(--text);
  overflow-x: auto; margin: 18px 0 20px;
}
pre.tree .c { color: var(--muted); }
.code-story { max-width: 68ch; margin-top: 30px; }
.code-story h3 { font-size: 22px; }

/* ------------------ /projects/constp/: instruments wider than the prose ------------------ */
/* the container widens so the walkthrough gets about 1200px; everything else in it keeps
   the usual 840px reading measure, centred. Scoped by .wide, so no other page shifts. */
.container.wide { max-width: 1240px; }
.container.wide > section > :not(.sim) { max-width: 840px; margin-left: auto; margin-right: auto; }
/* inside the wide walkthrough box, text runs the full width of the box */
.container.wide .sim .mod-intro,
.container.wide .sim .mod-section p { max-width: none; }

.connects { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); max-width: 68ch; }

/* ------------------ narrow screens ------------------ */
@media (max-width: 768px) {
  .sim-body { grid-template-columns: 1fr; }
  .mod-grid { grid-template-columns: 1fr; }
  .sim-code { font-size: 11.5px; }
  .paper-card { --pad-x: 18px; }          /* matches mobile.css card padding */
  .eq-hero { padding-top: 18px; padding-bottom: 18px; }
  .eq-hero .katex-display { font-size: 0.98rem; }
  .instrument { padding: 14px 12px; }
  html.m-on .values-table td.col-d { text-align: left; }
  html.m-on .values-table td.col-log { white-space: normal; }
}
@media (max-width: 480px) {
  .sim-controls { gap: 8px; }
  .sim-controls input[type="range"] { width: 70px; }
  .seg button { min-width: 36px; }
}
.nowrap { white-space: nowrap; }

/* one-line equations on wide screens, stacked where they would not fit */
@media (max-width: 719px) {
  .eq-bound .eq-wide { display: none; }
  .eq-bound .eq-narrow { display: block; }
}
@media (max-width: 500px) {
  .eq-lead .eq-wide { display: none; }
  .eq-lead .eq-narrow { display: block; }
}

/* small phones: keep every display equation inside its column */
@media (max-width: 400px) {
  .eq-hero .katex-display { font-size: 0.84rem; }
  .eq-lead .katex-display { font-size: 0.8em; }
  dl.results .katex-display { font-size: 0.9em; }
}
