/* Roller chain drive — on top of calc.css */
main.ch .tabs { grid-template-columns: repeat(2, 1fr); }
main.ch .stage-bar { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
main.ch .stage-bar .hist { margin-left: auto; }
#view { display: block; width: 100%; height: auto; user-select: none; touch-action: none; }
#view .hit { fill: transparent; stroke: none; }
#view .handle { cursor: grab; }
#view .handle.hx { cursor: ew-resize; }
#view .handle .knob { fill: var(--surface); stroke: var(--sel); stroke-width: 1.8; }
#view .handle:hover .knob, #view .handle:focus .knob { fill: var(--sel); }

/* pulleys and belt */
.ch-rim { fill: var(--steel-200); stroke: var(--steel-700); stroke-width: 1.1; }
.ch-web { fill: var(--steel-50); stroke: var(--steel-500); stroke-width: .8; }
.ch-hole { fill: var(--surface-2); stroke: var(--steel-500); stroke-width: .8; }
.ch-mark { stroke: var(--steel-500); stroke-width: 1.4; }
.ch-hub { fill: var(--steel-200); stroke: var(--steel-700); stroke-width: 1; }
.ch-key { fill: var(--steel-700); }
.ch-bore { fill: var(--surface); stroke: var(--steel-700); stroke-width: .9; }
.ch-datum { fill: none; stroke: var(--steel-500); stroke-width: .7; stroke-dasharray: 6 3 1.5 3; pointer-events: none; }
.ch-belt { fill: none; stroke: var(--steel-750); stroke-linejoin: round; pointer-events: none; }
.ch-tight { stroke: var(--steel-850); stroke-linecap: butt; pointer-events: none; }
.ch-run { fill: none; stroke: var(--steel-350); stroke-dasharray: 2 14; stroke-linecap: round; pointer-events: none; }
.ch-ctr { stroke: var(--steel-700); stroke-width: .9; }
.ch-wrap { fill: none; stroke: var(--sel); stroke-width: 1.2; stroke-dasharray: 3 2.5; pointer-events: none; }
.ch-ext { fill: none; stroke: var(--steel-400); stroke-width: .8; }
.ch-dim { fill: none; stroke: var(--steel-550); stroke-width: .9; }
.ch-dimh { fill: var(--steel-550); }
.ch-load line { stroke: var(--load); stroke-width: 1.8; }
.ch-load path { fill: var(--load); stroke: none; }
.ch-load.ch-grey line { stroke: var(--steel-550); } .ch-load.ch-grey path { fill: var(--steel-550); }
.ch-name { font-size: 12.5px; font-weight: 600; fill: var(--text); }
.ch-role { font-size: 11px; fill: var(--text-3); }
.ch-nm { cursor: text; }
.ch-nm:hover .ch-name, .ch-nm:focus .ch-name { fill: var(--sel); }
.ch-nm:focus { outline: none; }

/* pills */
#view .pill rect { fill: var(--surface); stroke: var(--steel-300); }
#view .pill text { font-size: 11.5px; font-weight: 500; fill: var(--text-2); font-variant-numeric: tabular-nums; }
#view .pill.dimv rect { stroke: var(--steel-200); }
#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.desig rect { stroke: color-mix(in srgb, var(--sel) 45%, transparent); } #view .pill.desig text { fill: var(--x-1e4fbf, #1e4fbf); font-weight: 600; }
#view .pill.desig { cursor: pointer; }
#view .pill.beta rect { stroke: color-mix(in srgb, var(--sel) 35%, transparent); } #view .pill.beta text { fill: var(--x-1e4fbf, #1e4fbf); }
#view .pill.set rect { stroke: var(--text-2); }
#view .pill.editable { cursor: text; }
#view .pill.editable:hover rect, #view .pill.editable:focus rect { stroke: var(--sel); stroke-width: 1.4; }
#view .pill.editable:focus { outline: none; }

/* editors in the drawing */
.stage { position: relative; }
.ch-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); }
.ch-edit input { width: 82px; border: 0; outline: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; padding: 3px 2px; }
.ch-edit-name input { width: 180px; text-align: center; }
.ch-edit span { font-size: 11.5px; color: var(--text-3); }

/* live strip and flags */
.ch-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: 38px; align-items: center; }
.ch-live b { font-weight: 500; color: var(--text-3); margin-right: 5px; }
.ch-live i { font-style: normal; color: var(--text-3); }
.ch-flags { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.ch-flags span { font-size: 11.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }

/* panel */
.ch-fam { font-size: 11.5px; color: var(--text-3); margin: 6px 0 4px; }
.ch-fam:first-child { margin-top: 0; }
.ch-profs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.ch-prof { display: grid; justify-items: center; gap: 0; padding: 4px 8px 3px; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface, #fff); cursor: pointer; font-size: 12px; color: var(--text-2); }
.ch-prof:hover { border-color: var(--line-2); }
.ch-prof.on { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); color: var(--text); }
.ch-seg { margin-bottom: 6px; }
.ch-snap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin: 2px 0 4px; font-size: 12px; color: var(--text-3); }
.ch-snap > span { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ch-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--text-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.ch-chip:hover { border-color: var(--line-2); }
.ch-chip.on { border-color: var(--text); color: var(--text); font-weight: 500; }
.ch-lab { font-size: 12px; color: var(--text-3); margin: 8px 0 4px; }
.ch-duty { display: grid; gap: 4px; }
.ch-card { display: grid; gap: 1px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--text); font-size: 12.5px; }
.ch-card b { font-weight: 500; }
.ch-card span { font-size: 11.5px; color: var(--text-3); line-height: 1.35; }
.ch-card:hover { border-color: var(--line-2); }
.ch-card.on { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
#panel input.bad { color: var(--bad); }
#panel .num:has(input.bad) input { border-color: var(--bad); }

/* summary */
.ch-say { margin-top: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.4; max-width: 34ch; }
.ch-des { font-weight: 600; color: var(--x-1e4fbf, #1e4fbf); }
.ch-tag { display: inline-block; font-size: 10.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; margin-left: 4px; white-space: nowrap; }

/* installation and the chart */
.ch-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.ch-inst-grid { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 16px; align-items: start; }
.ch-kv { display: grid; gap: 0; }
.ch-kv > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.ch-kv span { color: var(--text-2); }
.ch-kv b { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ch-kv i { grid-column: 1 / -1; font-style: normal; font-size: 11.5px; color: var(--text-3); }
.ch-gfig .small-note { margin-top: 4px; }
.ch-gcap { margin: 2px 0 0; font-size: 12px; color: var(--text-2); line-height: 1.4; }
.ch-groove { display: block; width: 100%; height: auto; }
.ch-pul { fill: var(--steel-200); stroke: var(--steel-700); stroke-width: 1; }
.ch-sec { fill: var(--steel-350); stroke: var(--steel-750); stroke-width: 1; }
.ch-gt { font-size: 12px; font-weight: 600; fill: var(--load); }
.ch-gs { font-size: 11.5px; fill: var(--text-2); }
.ch-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
#tchart .tdrag { cursor: ew-resize; }
#tchart { touch-action: none; user-select: none; }

/* other profiles */
table.ch-alt { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ch-alt th { font-weight: 500; font-size: 11.5px; color: var(--text-3); text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ch-alt td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ch-alt th.l, .ch-alt td.l { text-align: left; }
.ch-alt tr.sel td { background: var(--sel-bg); }
.ch-pn { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 1100px) { .ch-two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .ch-inst-grid { grid-template-columns: minmax(0, 1fr); }
  .ch-gfig { max-width: 300px; }
  table.ch-alt thead { display: none; }
  table.ch-alt, .ch-alt tbody, .ch-alt tr, .ch-alt td { display: block; width: 100%; }
  .ch-alt tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .ch-alt td { border: 0; padding: 0; text-align: left; white-space: normal; }
  .ch-alt td:nth-child(1) { font-weight: 500; }
  .ch-alt td:nth-child(3)::before { content: "sprockets "; color: var(--text-3); }
  .ch-alt td:nth-child(4)::before { content: "a "; color: var(--text-3); }
  .ch-alt td:nth-child(5)::before { content: "v "; color: var(--text-3); }
  .ch-alt td:nth-child(6)::before { content: "width "; color: var(--text-3); }
  .ch-alt td:nth-child(7)::before { content: "pull "; color: var(--text-3); }
  .ch-alt td:nth-child(8), .ch-alt td:nth-child(9) { text-align: right; }
  .ch-profs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
#panel.fade-b { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); }
#panel.fade-t { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px); mask-image: linear-gradient(to bottom, transparent, #000 28px); }
#panel.fade-t.fade-b { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); }
#checks td.note { white-space: normal; min-width: 200px; line-height: 1.4; }
/* phones: the margins as stacked cards (no sideways scroll) */
@media (max-width: 760px) {
  #checks thead { display: none; }
  #checks, #checks tbody { display: block; width: 100%; }
  #checks tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
  #checks td { display: block; border: 0; padding: 0; text-align: left; white-space: normal; }
  #checks td.chk { grid-column: 1; grid-row: 1; }
  #checks td:nth-child(5) { grid-column: 2; grid-row: 1; align-self: center; }
  #checks td:nth-child(2) { grid-column: 1; grid-row: 2; font-size: 12.5px; }
  #checks td:nth-child(3) { grid-column: 2; grid-row: 2; font-size: 12.5px; text-align: right; }
  #checks td:nth-child(2)::before { content: "actual "; color: var(--text-3); }
  #checks td:nth-child(3)::before { content: "allowed "; color: var(--text-3); }
  #checks td:nth-child(4) { grid-column: 1 / -1; grid-row: 3; font-size: 12px; color: var(--text-3); }
}
@media print { .ch-edit { display: none !important; } }

/* chain drive: sprockets and the chain */
.ch-spr { fill: var(--steel-200); stroke: var(--steel-700); stroke-width: 1; stroke-linejoin: round; }
.ch-pitch { fill: none; stroke: var(--steel-500); stroke-width: .7; stroke-dasharray: 6 3 1.5 3; pointer-events: none; }
.ch-plate { fill: none; stroke: var(--x-8f979f, #8f979f); stroke-linecap: round; pointer-events: none; }
.ch-plate.in { stroke: var(--steel-400); }
.ch-roller { fill: var(--steel-700); stroke: var(--steel-850); stroke-width: .6; pointer-events: none; }
.ch-pin { fill: var(--steel-150); pointer-events: none; }
.ch-tightln { stroke: color-mix(in srgb, var(--load) 18%, transparent); stroke-linecap: round; pointer-events: none; }
.ch-sizes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.ch-size { display: grid; justify-items: center; gap: 0; padding: 4px 6px 3px; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface, #fff); cursor: pointer; font-size: 12px; color: var(--text-2); }
.ch-size small { font-size: 10.5px; color: var(--text-3); }
.ch-size:hover { border-color: var(--line-2); }
.ch-size.on { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); color: var(--text); }
.ch-sprt { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ch-sprt th { font-weight: 500; font-size: 11.5px; color: var(--text-3); text-align: right; padding: 5px 6px; border-bottom: 1px solid var(--line); }
.ch-sprt td { text-align: right; padding: 5px 6px; border-bottom: 1px solid var(--line); }
.ch-sprt th.l, .ch-sprt td.l { text-align: left; }
.ch-charts { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; }
#rchart .rdrag, #pchart .pdrag { cursor: ew-resize; }
#rchart, #pchart { touch-action: none; user-select: none; }
@media (max-width: 1100px) { .ch-charts { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .ch-sizes { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.srcs .sc { font-size: 10.5px; color: var(--text-2); background: var(--fill-1); border-radius: 4px; padding: 0 5px; }
#rchart .rpill, #pchart .ppill { cursor: ew-resize; }
.ch-kv b { white-space: normal; overflow-wrap: anywhere; }

/* 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-1e4fbf: #749ff5; --x-6e7177: #85827f; --x-8a6d1f: #c2a96f; --x-8f979f: #61676d;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-1e4fbf: #749ff5; --x-6e7177: #85827f; --x-8a6d1f: #c2a96f; --x-8f979f: #61676d;
  }
}
/* theme-auto:end */
