/* Worm gears — on top of calc.css */
main.wg .tabs { grid-template-columns: repeat(3, 1fr); }
main.wg .stage-bar { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
main.wg .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.hy { cursor: ns-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); }

/* parts */
.wg-wheel { fill: var(--x-ece3d2, #ece3d2); stroke: var(--x-6d5a3a, #6d5a3a); stroke-width: 1; stroke-linejoin: round; }
.wg-web { fill: var(--steel-50); stroke: var(--steel-550); stroke-width: .8; }
.wg-hole { fill: var(--surface-2); stroke: var(--steel-500); stroke-width: .8; }
.wg-hub { fill: var(--steel-200); stroke: var(--steel-700); stroke-width: 1; }
.wg-key { fill: var(--steel-700); }
.wg-bore { fill: var(--surface); stroke: var(--steel-700); stroke-width: .9; }
.wg-pitch { fill: none; stroke: var(--steel-550); stroke-width: .7; stroke-dasharray: 7 3 1.5 3; pointer-events: none; }
.wg-worm { fill: url(#hatchSteel); stroke: var(--steel-750); stroke-width: 1; stroke-linejoin: round; }
.wg-wormf { fill: var(--steel-250); stroke: var(--steel-750); stroke-width: 1; }
.wg-shaft { fill: var(--steel-200); stroke: var(--steel-700); stroke-width: 1; }
.wg-rim { fill: url(#hatchBronze); stroke: var(--x-6d5a3a, #6d5a3a); stroke-width: 1; stroke-linejoin: round; }
.wg-body { fill: url(#hatchIron); stroke: var(--steel-700); stroke-width: 1; stroke-linejoin: round; }
.wg-axis { stroke: var(--steel-550); stroke-width: .7; stroke-dasharray: 9 3 1.5 3; fill: none; pointer-events: none; }
.wg-ctr { stroke: var(--steel-700); stroke-width: .9; }
.wg-ext { fill: none; stroke: var(--steel-400); stroke-width: .8; }
.wg-dim { fill: none; stroke: var(--steel-550); stroke-width: .9; }
.wg-dimh { fill: var(--steel-550); }
.wg-lead { stroke: color-mix(in srgb, var(--load) 55%, transparent); stroke-width: .9; pointer-events: none; }
.wg-cap { font-size: 11.5px; fill: var(--text-3); }
.wg-sec { font-size: 11px; font-weight: 600; fill: var(--text-2); letter-spacing: .04em; }
.wg-load line, .wg-load path.sh { stroke: var(--load); stroke-width: 1.8; fill: none; }
.wg-load path.hd { fill: var(--load); stroke: none; }
.wg-load.wg-grey line, .wg-load.wg-grey path.sh { stroke: var(--steel-550); } .wg-load.wg-grey path.hd { fill: var(--steel-550); }
.wg-spin { fill: none; stroke: var(--sel); stroke-width: 1.2; }
.wg-spinh { fill: var(--sel); }
.wg-dot { fill: var(--load); }
.wg-x { stroke: var(--load); stroke-width: 1.6; fill: var(--surface); }
.wg-name { font-size: 12.5px; font-weight: 600; fill: var(--text); }
.wg-role { font-size: 11px; fill: var(--text-3); }
.wg-nm { cursor: text; }
.wg-nm:hover .wg-name, .wg-nm:focus .wg-name { fill: var(--sel); }
.wg-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.lock rect { stroke: color-mix(in srgb, var(--good) 45%, transparent); } #view .pill.lock text { fill: var(--good); font-weight: 600; }
#view .pill.free rect { stroke: color-mix(in srgb, var(--amber) 55%, transparent); } #view .pill.free text { fill: var(--x-9a6b12, #9a6b12); font-weight: 600; }
#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; }
.wg-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); }
.wg-edit input { width: 82px; border: 0; outline: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; padding: 3px 2px; }
.wg-edit-name input { width: 180px; text-align: center; }
.wg-edit span { font-size: 11.5px; color: var(--text-3); }

/* live strip and flags */
.wg-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; }
.wg-live b { font-weight: 500; color: var(--text-3); margin-right: 5px; }
.wg-live i { font-style: normal; color: var(--text-3); }
.wg-flags { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.wg-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 */
.wg-seg { margin-bottom: 6px; }
.wg-lab { font-size: 12px; color: var(--text-3); margin: 8px 0 4px; }
.wg-lab:first-child { margin-top: 0; }
.wg-cards { display: grid; gap: 4px; }
.wg-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; }
.wg-card b { font-weight: 500; }
.wg-card span { font-size: 11.5px; color: var(--text-3); line-height: 1.35; }
.wg-card:hover { border-color: var(--line-2); }
.wg-card.on { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.wg-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 6px; }
.wg-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; }
.wg-chip:hover { border-color: var(--line-2); }
.wg-chip.on { border-color: var(--text); color: var(--text); font-weight: 500; }
.wg-sel select { width: 100%; }
#panel input.bad { color: var(--bad); }
#panel .num:has(input.bad) input { border-color: var(--bad); }
.wg-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); margin: 6px 0 2px; cursor: pointer; }

/* summary */
.wg-say { margin-top: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.4; max-width: 34ch; }
.wg-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; }
.wg-lockv { font-weight: 600; }
.wg-lockv.lock { color: var(--good); } .wg-lockv.free { color: var(--x-9a6b12, #9a6b12); }

/* forces and chart */
.wg-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.wg-kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 18px; }
.wg-kv h3 { grid-column: 1 / -1; font-size: 12px; font-weight: 500; color: var(--text-3); margin: 10px 0 2px; }
.wg-kv h3:first-child { margin-top: 0; }
.wg-kv > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.wg-kv span { color: var(--text-2); }
.wg-kv b { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wg-kv i { grid-column: 1 / -1; font-style: normal; font-size: 11.5px; color: var(--text-3); }
#echart .edrag { cursor: ew-resize; }
.wg-rest { margin-top: 10px; }
#echart { touch-action: none; user-select: none; }

/* materials */
table.wg-alt { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.wg-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; }
.wg-alt td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.wg-alt th.l, .wg-alt td.l { text-align: left; }
.wg-alt td.l { white-space: normal; }
.wg-alt tr.sel td { background: var(--sel-bg); }
.wg-alt td.meth { color: var(--text-3); }

@media (max-width: 1100px) { .wg-two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .wg-kv { grid-template-columns: minmax(0, 1fr); }
  table.wg-alt thead { display: none; }
  table.wg-alt, .wg-alt tbody, .wg-alt tr, .wg-alt td { display: block; width: 100%; }
  .wg-alt tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .wg-alt td { border: 0; padding: 0; text-align: left; white-space: normal; }
  .wg-alt td:nth-child(1) { font-weight: 500; }
  .wg-alt td:nth-child(3)::before { content: "factor "; color: var(--text-3); }
  .wg-alt td:nth-child(4)::before { content: "allowable "; color: var(--text-3); }
  .wg-alt td:nth-child(5), .wg-alt td:nth-child(6) { text-align: right; }
}
#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 { .wg-edit { display: none !important; } }

/* 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-6d5a3a: #a69579; --x-6e7177: #85827f; --x-9a6b12: #cfa76a; --x-b49a6b: #b6a17b;
    --x-e8d7a6: #433714; --x-ece3d2: #363025;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-1e4fbf: #749ff5; --x-6d5a3a: #a69579; --x-6e7177: #85827f; --x-9a6b12: #cfa76a; --x-b49a6b: #b6a17b;
    --x-e8d7a6: #433714; --x-ece3d2: #363025;
  }
}
/* theme-auto:end */
