/* thread engagement — on top of calc.css */
main.thr { --ext: var(--moment); --int: var(--clamp); --par: var(--ochre); }
main.thr .stage-bar { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
main.thr .stage-bar .hist { margin-left: auto; }
#view { display: block; width: 100%; height: auto; flex: 1; min-height: 0; user-select: none; touch-action: none; }
#view.dragging, #view.dragging * { cursor: grabbing !important; }
#view .handle { cursor: grab; }
#view .handle.v { cursor: ns-resize; }
#view .handle.h { cursor: ew-resize; }
#view .handle .knob { fill: var(--surface); stroke: var(--sel); stroke-width: 1.8; }
#view .handle:hover .knob { fill: var(--sel); }

/* flat, quiet section */
#view .part { fill: var(--steel-200); stroke: var(--steel-600); stroke-width: .9; stroke-linejoin: round; }
#view .plate { fill: var(--steel-100); stroke: var(--steel-500); stroke-width: .8; }
#view .boltf { fill: var(--steel-50); stroke: var(--steel-700); stroke-width: .9; stroke-linejoin: round; }
#view .coil { fill: var(--steel-350); stroke: var(--steel-650); stroke-width: .6; }
#view .ring { fill: var(--steel-200); stroke: var(--bad); stroke-width: .9; }
#view .brk { fill: none; stroke: var(--steel-700); stroke-width: 1.1; }
#view .cl { stroke: var(--steel-500); stroke-width: .7; stroke-dasharray: 12 3 2 3; fill: none; }
#view .dimln { stroke: var(--steel-550); stroke-width: .8; fill: none; }
#view .band { fill: color-mix(in srgb, var(--sel) 6%, transparent); }
#view .shear { fill: none; stroke-width: 1.2; stroke-dasharray: 4 3; opacity: .9; }
#view .shear.focus { stroke-width: 2.6; }
#view .lbar { fill: var(--steel-500); }
#view .lbar.first { fill: var(--steel-700); }
#view .cap { font-size: calc(11px * var(--tk, 1)); fill: var(--text-3); }
#view .capb { font-size: calc(11.5px * var(--tk, 1)); fill: var(--text-2); font-weight: 500; }
#view .pill rect { fill: var(--surface); stroke: var(--steel-300); }
#view .pill text { font-size: calc(11.5px * var(--tk, 1)); font-weight: 500; fill: var(--text-2); font-variant-numeric: tabular-nums; }
#view .pill.editable { cursor: text; }
#view .pill.editable:hover rect { stroke: var(--sel); stroke-width: 1.4; }
#view .pill.editable:focus { outline: none; }
#view .pill.editable:focus rect { stroke: var(--sel); stroke-width: 1.6; }
#view .pill.load rect { stroke: color-mix(in srgb, var(--load) 35%, transparent); } #view .pill.load text { fill: var(--load); font-weight: 600; }
#view .pill.bad rect { stroke: var(--bad); } #view .pill.bad text { fill: var(--bad); }
#view .pill.warn rect { stroke: var(--warn); } #view .pill.warn text { fill: var(--x-9a6a12, #9a6a12); }
#view .pill.good rect { stroke: var(--good); } #view .pill.good text { fill: var(--good); }
#view .pill.ext text { fill: var(--ext); } #view .pill.int text { fill: var(--int); } #view .pill.par text { fill: var(--par); }
#view .pill.title text { fill: var(--text); font-weight: 600; }
/* detail A */
#view .dt-frame { fill: var(--surface-2); stroke: var(--line); }
#view .dt-ext { fill: var(--steel-50); stroke: var(--steel-700); stroke-width: 1; stroke-linejoin: round; }
#view .dt-int { fill: var(--steel-200); stroke: var(--steel-600); stroke-width: 1; stroke-linejoin: round; }
#view .dt-zone-e { fill: color-mix(in srgb, var(--moment) 16%, transparent); }
#view .dt-zone-i { fill: color-mix(in srgb, var(--clamp) 16%, transparent); }
#view .dt-max { fill: none; stroke-width: .9; stroke-dasharray: 3 2; }
#view .dt-basic { fill: none; stroke: var(--steel-400); stroke-width: .7; stroke-dasharray: 1 2; }
#view .dt-dia { stroke: var(--faint); stroke-width: .6; }
#view .dt-lab { font-size: calc(10.5px * var(--tk, 1)); fill: var(--text-2); font-variant-numeric: tabular-nums; }
#view .dt-cut { stroke-width: 3.2; stroke-linecap: round; }
#view .leader { stroke: var(--steel-400); stroke-width: .8; fill: none; }

.th-live { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; min-height: 34px; align-items: center; }
.th-live b { font-weight: 500; color: var(--text-3); margin-right: 4px; }
.th-live .x-ok { color: var(--good); font-weight: 500; }
.th-live .x-no { color: var(--bad); font-weight: 500; }

/* in-place editor (values in the drawing) */
.th-edit { position: absolute; transform: translate(-50%, -50%); z-index: 5; display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1.5px solid var(--sel); border-radius: 9px; padding: 2px 8px 2px 4px; box-shadow: 0 6px 18px rgba(20, 22, 28, .14); }
.th-edit input { width: 92px; border: 0; outline: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; padding: 3px 2px; }
.th-edit input.txt { text-align: left; width: 120px; }
.th-edit span { font-size: 11.5px; color: var(--text-3); }
.th-edit.bad { border-color: var(--bad); }
.stage { position: relative; }

/* examples menu */
.ex-wrap { position: relative; }

/* panel bits */
.th-name { display: grid; gap: 4px; }
.th-name input { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; font-size: 15px; font-weight: 500; outline: none; background: var(--surface); }
.th-name input:focus { border-color: var(--text-2); }
.th-name input.bad { border-color: var(--bad); }
.th-name .msg { font-size: 12px; color: var(--text-3); min-height: 16px; }
.th-name .msg.bad { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.chip.on { border-color: var(--text); color: var(--text); font-weight: 500; }
.f.segf { grid-template-columns: minmax(0, 1fr) auto; }
.f.segf .seg button { padding: 4px 9px; font-size: 12.5px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12.5px; color: var(--text-2); margin: 4px 0 0; font-variant-numeric: tabular-nums; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; text-align: right; }
.src-tag { font-size: 11px; color: var(--text-3); }
.src-tag a { color: var(--text-3); }

/* summary */
.th-sum { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
.story { padding: 14px 20px; display: grid; align-content: center; gap: 6px; min-width: 0; }
.story p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text); max-width: 72ch; }
.story p.sub { font-size: 12.5px; color: var(--text-2); }
.story .mode { display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.story .mode svg { flex: none; }
.th-mini { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); border-left: 1px solid var(--line); }
.th-mini .stat { border-left: 0; border-top: 1px solid var(--line); }
.th-mini .stat:nth-child(-n+2) { border-top: 0; }
.th-mini .stat:nth-child(even) { border-left: 1px solid var(--line); }
@media (max-width: 1320px) {
  .th-sum { grid-template-columns: minmax(0, 1fr); }
  .th-mini { grid-template-columns: repeat(4, minmax(0, 1fr)); border-left: 0; border-top: 1px solid var(--line); }
  .th-mini .stat { border-top: 0; border-left: 1px solid var(--line); }
  .th-mini .stat:first-child { border-left: 0; }
}
@media (max-width: 700px) {
  .th-mini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .th-mini .stat:nth-child(odd) { border-left: 0; }
  .th-mini .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* margins */
#checks tr[data-check] { cursor: pointer; }
#checks td.note { white-space: normal; min-width: 180px; }
#checks .guide-tag { font-size: 11px; color: var(--text-3); margin-left: 6px; }
table.pitch tr.cur td { background: var(--bg); }
table.pitch tr.cur td.l { font-weight: 600; }
table.pitch tbody tr { cursor: pointer; }

/* chart + fixes */
.th-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
#chart { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
#chart .drag { cursor: ew-resize; }
.ch-t { font-size: 10.5px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.ch-a { font-size: 11px; fill: var(--text-2); }
.ch-l { font-size: 11px; font-weight: 600; }
.fixes { display: grid; gap: 8px; }
.fix { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.fix b { font-weight: 600; font-size: 13.5px; }
.fix p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.fix .ms { margin-left: 6px; }
.fix.done { background: var(--surface-2); }
@media (max-width: 1040px) { .th-row { grid-template-columns: minmax(0, 1fr); } }

/* steps: governing step marked */
details.step.gov > summary .t::after { content: "governs"; margin-left: 10px; font-size: 11px; font-weight: 600; color: var(--bad); letter-spacing: .03em; text-transform: uppercase; }
.step .where { font-size: 12px; color: var(--text-3); margin: 6px 0 0; line-height: 1.6; }
.step .where i { font-style: normal; color: var(--text-2); }
.refs-body .md-src li { margin: 5px 0; }
.sec-tag { font-style: normal; font-size: 11px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin-left: 4px; }

@media (max-width: 560px) {
  .ex-menu { min-width: 260px; }
  .story { padding: 12px 14px; }
}

.f.segf.stack { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.f.segf.stack .seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; }
#checks td.l:first-child { white-space: normal; min-width: 120px; }
@media (max-width: 700px) {
  #checks th:nth-child(4), #checks td:nth-child(4) { display: none; }
  table.pitch th:nth-child(3), table.pitch td:nth-child(3), table.pitch th:nth-child(5), table.pitch td:nth-child(5) { display: none; }
  .margins td, .margins th { padding-left: 4px; padding-right: 4px; }
  .margins .ms { min-width: 54px; padding: 2px 6px; }
  .step .eq .katex { font-size: .86em; }
  #checks td.l:first-child { min-width: 0; }
}
@media (max-width: 420px) {
  table.pitch th:nth-child(2), table.pitch td:nth-child(2) { display: none; }
}
#view .badge circle { fill: var(--surface); stroke: var(--steel-700); stroke-width: 1; }
#view .badge text { font-size: calc(10.5px * var(--tk, 1)); font-weight: 600; fill: var(--text); }
#view .leader { stroke: var(--steel-550); stroke-width: .9; fill: none; stroke-dasharray: 3 2; }
#view .ring { transition: none; }
#view .dt-coil { fill: var(--steel-350); stroke: var(--steel-650); stroke-width: .8; stroke-linejoin: round; }
#view .lpct { font-size: calc(9.5px * var(--tk, 1)); fill: var(--text-3); font-variant-numeric: tabular-nums; }
#view .lpct.first { fill: var(--text-2); font-weight: 600; }
#view.narrow .lpct { font-size: calc(10.5px * var(--tk, 1)); }
#angleCard[hidden] { display: none; }
.ach-wrap { display: flex; gap: 18px; align-items: flex-start; }
#achart { display: block; flex: 1; min-width: 0; width: 100%; height: auto; touch-action: none; user-select: none; }
#achart .adrag { cursor: ew-resize; }
.ach-read { flex: 0 0 230px; font-size: 12.5px; color: var(--text-2); }
.ach-read h4 { margin: 2px 0 8px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.ach-read ol { list-style: none; margin: 0; padding: 0; }
.ach-read li { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--line); }
.ach-read li i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; transform: translateY(1px); }
.ach-read li b { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text); }
.ach-read li.gov span, .ach-read li.gov b { font-weight: 600; }
.ach-read .gtag { font-size: 11px; color: var(--text-3); margin-left: 4px; font-weight: 400; }
.ach-read .crosby { margin-top: 10px; font-size: 12px; color: var(--text-3); line-height: 1.4; }
.ach-cap { margin: 8px 0 0; font-size: 13px; color: var(--text); }
#checks tr.hl td { background: color-mix(in srgb, var(--sel) 6%, transparent); }
@media (max-width: 860px) { .ach-wrap { flex-direction: column; } .ach-read { flex: none; width: 100%; } }
/* reserve the summary's height so the cards below do not jump when the page script fills it */
main.thr #summary { min-height: 183px; }
@media (max-width: 1320px) { main.thr #summary { min-height: 250px; } }
@media (max-width: 1040px) { main.thr #summary { min-height: 380px; } }
@media (max-width: 700px) { main.thr #summary { min-height: 520px; } }
main.thr .table-wrap:has(> #checks:empty) { min-height: 260px; }

/* bolt-length view: stack, head, washers, ruler */
#lenBtn[aria-pressed="true"] { background: var(--sel); border-color: var(--sel); color: var(--on-accent); }
#view .plate.p2 { fill: var(--steel-150); }
#view .head { fill: var(--steel-blue); }
#view .hedge { stroke: var(--steel-550); stroke-width: .7; }
#view .hidden-ln { fill: none; stroke: var(--steel-550); stroke-width: .7; stroke-dasharray: 3 2; }
#view .washer { fill: var(--steel-300); stroke: var(--steel-650); stroke-width: .7; }
#view .washer.hard { fill: var(--faint); }
#view .washer.nl { fill: var(--steel-350); stroke: var(--x-56606b, #56606b); stroke-width: .7; stroke-linejoin: round; }
#view .nl-ser { fill: none; stroke: var(--x-56606b, #56606b); stroke-width: .5; }
#view .wsplit { stroke: var(--halo); stroke-width: 1.6; }
#view .pill.ghost rect { fill: var(--surface-2); stroke-dasharray: 3 2; } #view .pill.ghost text { fill: var(--text-3); }
#view .rspine { stroke: var(--steel-700); stroke-width: 1; }
#view .rtick { stroke: var(--steel-550); stroke-width: .7; }
#view .rnow { fill: var(--sel); }
#view .rlab { font-size: calc(11px * var(--tk, 1)); font-weight: 600; font-variant-numeric: tabular-nums; }
#view .rlab.now { fill: var(--sel); font-style: italic; }
#view .lenpick { cursor: pointer; }
#view .lenpick.off { cursor: default; opacity: .55; }
#view .lenpick .hit { fill: transparent; }
#view .lenpick:not(.off):hover .hit, #view .lenpick:focus .hit { fill: color-mix(in srgb, var(--sel) 8%, transparent); }
#view .lenpick:focus { outline: none; }
#view .lenpick.cur .rlab { text-decoration: underline; }
#view .tband { fill: color-mix(in srgb, var(--good) 9%, transparent); }
#view .tband.strong { fill: color-mix(in srgb, var(--good) 45%, transparent); }
#view .tline { stroke-width: 1.4; fill: none; }
#view .tline.good { stroke: var(--good); }
#view .tline.bad { stroke: var(--bad); stroke-dasharray: 6 3; }
#view .trule { stroke: var(--steel-550); stroke-width: 1.2; }
#view .tlead { stroke-width: .7; fill: none; opacity: .7; }
#view .tlead.good { stroke: var(--good); } #view .tlead.bad { stroke: var(--bad); } #view .tlead.now { stroke: var(--sel); } #view .tlead.rule { stroke: var(--steel-550); }
#view .ttag { font-size: calc(11px * var(--tk, 1)); fill: var(--text-2); font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--halo); stroke-width: 3px; stroke-linejoin: round; }
#view .ttag.b { font-weight: 600; }
#view .ttag.good.b { fill: var(--good); } #view .ttag.bad.b { fill: var(--bad); } #view .ttag.now.b { fill: var(--sel); } #view .ttag.rule { fill: var(--text-3); }
.th-len { padding: 10px 14px 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.th-len[hidden] { display: none; }
.th-len .len-say { margin: 0 0 8px; color: var(--text); }
.th-len .len-row { display: flex; gap: 10px; align-items: flex-start; }
.th-len .len-k { font-size: 12px; color: var(--text-3); white-space: nowrap; padding-top: 4px; }
.th-len .lchips { display: flex; flex-wrap: wrap; gap: 4px; }
.th-len .lchip { font: inherit; font-size: 12px; font-variant-numeric: tabular-nums; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.th-len .lchip.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); background: color-mix(in srgb, var(--good) 7%, transparent); }
.th-len .lchip.warn { color: var(--x-9a6a12, #9a6a12); border-color: color-mix(in srgb, var(--amber) 50%, transparent); }
.th-len .lchip.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.th-len .lchip:disabled { opacity: .45; cursor: default; }
.th-len .lchip.on { font-weight: 700; box-shadow: 0 0 0 1.5px var(--sel); }
.th-len .lchip:not(:disabled):hover { border-color: var(--sel); }
.th-len .len-now { margin: 8px 0 0; font-size: 12.5px; }
.th-len .len-now .good { color: var(--good); } .th-len .len-now .warn { color: var(--x-9a6a12, #9a6a12); } .th-len .len-now .bad { color: var(--bad); }
.th-len .len-notes { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text-2); }
.th-len .len-notes li { margin: 2px 0; }
@media (max-width: 700px) { .th-len .len-row { flex-direction: column; gap: 4px; } }

/* margins: row pictures and failure previews (screen only) */
#checks td.chk { display: flex; align-items: center; gap: 10px; }
#checks td.chk .th { flex: none; width: 40px; height: 40px; margin: -6px 0; border-radius: 7px; box-shadow: inset 0 0 0 1px var(--line); }
#checks td.chk:focus-visible { outline: 2px solid var(--sel); outline-offset: -2px; border-radius: 6px; }
.th-pv { position: fixed; z-index: 60; width: 220px; padding: 8px 8px 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(20, 24, 30, .14); pointer-events: none; font-size: 12px; color: var(--text); }
.th-pv[hidden] { display: none; }
.th-pv svg { display: block; width: 204px; height: auto; margin: 4px 0 6px; }
.th-pv .pv-h { font-weight: 600; font-size: 12px; color: var(--text); line-height: 1.3; }
.th-pv .pv-c { color: var(--text-2); line-height: 1.35; }
.th-pv .pv-m { margin-top: 4px; color: var(--text-3); }
@media print { .th-pv { display: none !important; } }
.th-tip { position: fixed; z-index: 70; max-width: 280px; padding: 6px 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(20, 24, 30, .12); font-size: 12px; line-height: 1.35; color: var(--text-2); pointer-events: none; }
.th-tip[hidden] { display: none; }
@media print { .th-tip { display: none !important; } }
/* phones: the charts use a narrower frame and larger type (≥ 10 px on screen) */
svg.narrow .ch-t { font-size: 12.5px; }
svg.narrow .ch-a, svg.narrow .ch-l { font-size: 13px; }
#view .pill text.pl2 { font-size: calc(10.5px * var(--tk, 1)); font-weight: 400; fill: var(--text-3); }
.th-live .fmech { color: var(--text-2); }
.th-live .fmech b { font-weight: 600; margin-right: 6px; }
main.thr .stage-bar > .sb-break { display: none; }
@media (max-width: 700px) {
  main.thr .stage-bar { gap: 6px; }
  main.thr .stage-bar .btn.small { padding-left: 10px; padding-right: 10px; }
  main.thr .stage-bar .sb-wide { display: none; }
  /* undo/redo sit at the right end of the mode switch's row */
  main.thr .stage-bar { position: relative; }
  main.thr .stage-bar > .hist { position: absolute; right: 10px; top: 10px; margin: 0; }
  main.thr .stage-bar > .seg { max-width: calc(100% - 76px); grid-auto-columns: auto; }
  main.thr .stage-bar > .sb-break { display: block; flex-basis: 100%; height: 0; }
  main.thr .stage-bar > .seg button { padding-left: 9px; padding-right: 9px; min-width: 0; flex: 0 1 auto; white-space: nowrap; }
}

/* theme-auto:start · generated by scripts/theme/hexmap.py: dark values (the rule of scripts/theme/colour.py) for
   colours that are not tokens, written as var(--x-rrggbb, #rrggbb): light is the fallback, unchanged */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --x-365f9f: #80a5de; --x-3c8c83: #7cbab2; --x-4f5862: #929aa3; --x-55678f: #8c9dc0; --x-56606b: #8a939d;
    --x-5b84c2: #93b7ec; --x-6e7177: #85827f; --x-7a5fb5: #b39ee9; --x-86a9d8: #9fbce3; --x-9a6a12: #d0a66a;
    --x-b0608c: #e09abe; --x-b4cbe8: #3f4f63; --x-b8392b: #f28676; --x-c98a35: #e9b474; --x-d9694a: #fe9d83;
    --x-e79a73: #fab998; --x-efc3a6: #70513c; --x-f4c7bf: #533531; --x-f6d9d3: #402e2b; --x-f6e3d6: #382c24;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-365f9f: #80a5de; --x-3c8c83: #7cbab2; --x-4f5862: #929aa3; --x-55678f: #8c9dc0; --x-56606b: #8a939d;
    --x-5b84c2: #93b7ec; --x-6e7177: #85827f; --x-7a5fb5: #b39ee9; --x-86a9d8: #9fbce3; --x-9a6a12: #d0a66a;
    --x-b0608c: #e09abe; --x-b4cbe8: #3f4f63; --x-b8392b: #f28676; --x-c98a35: #e9b474; --x-d9694a: #fe9d83;
    --x-e79a73: #fab998; --x-efc3a6: #70513c; --x-f4c7bf: #533531; --x-f6d9d3: #402e2b; --x-f6e3d6: #382c24;
  }
}
/* theme-auto:end */
