/* motor sizing — on top of calc.css */
#view { display: block; width: 100%; height: auto; flex: 1; min-height: 0; user-select: none; touch-action: none; }
#view .loadblk { cursor: grab; }
#view.dragging, #view.dragging * { cursor: grabbing !important; }
#view .loadblk:hover rect, #view .loadblk:hover path, #view .loadblk:hover ellipse { stroke: var(--sel); }
#view .handle { cursor: grab; }
#view .handle .hit { fill: transparent; }
#view .handle .knob { fill: var(--surface); stroke: var(--sel); stroke-width: 1.8; }
#view .handle:hover .knob { fill: var(--sel); }
#view .pill rect { fill: var(--surface); stroke: var(--steel-300); }
#view .pill text { font-size: 11.5px; font-weight: 500; fill: var(--text-2); }
#view .pill.load rect, #view .pill.tq rect { stroke: color-mix(in srgb, var(--load) 35%, transparent); }
#view .pill.load text, #view .pill.tq text { fill: var(--load); font-weight: 600; }
#view .pill.mass rect { fill: color-mix(in srgb, var(--surface) 92%, transparent); }
#view .pill.mass text { fill: var(--text); font-weight: 600; }
#view .pill.mot text { fill: var(--text); }
#view .pill.dimv rect { stroke: var(--steel-200); }
#view .pill.editable { cursor: pointer; }
#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; }
.mo-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); }
.mo-edit input { width: 82px; border: 0; outline: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; padding: 3px 2px; }
.mo-edit span { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* stage bar: run, examples, mechanism pictures, history */
main.mo .stage { position: relative; padding-left: 6px; padding-right: 6px; }
main.mo .stage-bar { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
main.mo .stage-bar .hist { margin-left: auto; }
.stage-bar .btn.small { padding: 4px 10px; font-size: 12.5px; }
#play { min-width: 118px; background: var(--sel); border-color: var(--sel); color: var(--on-accent); font-weight: 600; }
#play:hover { filter: brightness(1.08); }
body.running #play { border-color: var(--sel); color: var(--sel); background: var(--surface); }
.mech-pick { display: flex; align-items: center; gap: 2px; background: var(--fill-1); border-radius: 8px; padding: 2px; margin-left: 4px; }
.mech-pick .mp { border: 0; background: none; border-radius: 6px; padding: 2px 3px; cursor: pointer; line-height: 0; }
.mech-pick .mp:hover { background: var(--line); }
.mech-pick .mp.on { background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.mech-pick .mp:focus-visible { outline: 2px solid var(--sel); outline-offset: -2px; }
.mech-pick .mp-name { font-size: 12.5px; font-weight: 500; color: var(--text); padding: 0 8px 0 6px; white-space: nowrap; }

.mo-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; }
.mo-live b { font-weight: 500; color: var(--text-3); margin-right: 4px; }
.mo-live .verdict-s { font-weight: 600; margin-right: 6px; }
.mo-live .verdict-s b { color: var(--text-3); font-weight: 400; margin: 0 0 0 4px; }
.mo-live .clock { margin-left: auto; color: var(--sel); font-weight: 600; }

/* panel */
#panel input.bad { color: var(--bad); }
#panel .num:has(input.bad) { border-color: var(--bad); }
#panel .seg.full { margin: 2px 0 8px; }
#panel input.txt { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 6px 9px; font-size: 13px; outline: none; }
#panel .f > label span { white-space: normal; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--sel); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.segc { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px 8px; margin-bottom: 8px; background: var(--surface); }
.segc.sel { background: var(--surface-2); }
.segc-h { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; }
.segc-h .segn { flex: 1; min-width: 0; border: 1px solid transparent; background: none; border-radius: 6px; padding: 4px 6px; margin-left: -6px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text); outline: none; }
.segc-h .segn:hover { border-color: var(--line); }
.segc-h .segn:focus { border-color: var(--text-2); background: var(--surface); }
.segc-h .segn::placeholder { color: var(--text); opacity: 1; }
.segc-k { font-size: 11.5px; color: var(--text-3); }
.segc .x { border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.segc .x:hover { background: var(--bad-bg); color: var(--bad); }
.seg-ro { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12px; color: var(--text-3); padding: 4px 0 0; font-variant-numeric: tabular-nums; }
.seg-ro b { font-weight: 500; color: var(--text-2); }
.seg-add { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-add .btn.small { padding: 4px 10px; font-size: 12.5px; }
table.mo-spec { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 2px 0 6px; }
table.mo-spec th { text-align: left; font-weight: 400; color: var(--text-3); padding: 5px 8px 5px 0; border-top: 1px solid var(--fill-1); vertical-align: top; white-space: nowrap; }
table.mo-spec td { text-align: right; padding: 5px 0; border-top: 1px solid var(--fill-1); color: var(--text); font-variant-numeric: tabular-nums; }
table.mo-spec .muted, .mo-guide .muted { color: var(--text-3); font-size: 11.5px; }
.mo-guide { list-style: none; margin: 0 0 4px; padding: 0; font-size: 12.5px; }
.mo-guide li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 5px 0; border-top: 1px solid var(--fill-1); color: var(--text-2); }
.mo-guide li b { font-weight: 500; color: var(--text); text-align: right; white-space: nowrap; }

/* summary */
main.mo .summary { min-height: 108px; }
.verdict .mo-mot { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.mo-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mo-stats .stat:nth-child(3n + 1) { border-left: 0; }
.mo-stats .stat:nth-child(n + 4) { border-top: 1px solid var(--line); }
@media (min-width: 1300px) {
  .mo-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .mo-stats .stat:nth-child(3n + 1) { border-left: 1px solid var(--line); }
  .mo-stats .stat:first-child { border-left: 0; }
  .mo-stats .stat:nth-child(n + 4) { border-top: 0; }
}
@media (max-width: 700px) {
  .mo-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mo-stats .stat:nth-child(3n + 1) { border-left: 1px solid var(--line); }
  .mo-stats .stat:nth-child(odd) { border-left: 0; }
  .mo-stats .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
  main.mo .summary { grid-template-columns: minmax(0, 1fr); }
}

/* margins table */
#checks tr[data-check] { cursor: pointer; }
#checks tr.sel td { background: var(--sel-bg); }
table.moms td.note { font-size: 12px; }
@media (max-width: 760px) { .mo-det { display: none; } }
@media (max-width: 480px) { .mo-alw { display: none; } }

/* charts */
#profChart, #tsChart, #iChart { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
#profChart { cursor: ew-resize; }
#profChart .handle, #tsChart .handle { cursor: grab; }
#profChart .handle .hit, #tsChart .handle .hit { fill: transparent; }
#profChart .handle .knob, #tsChart .handle .knob { fill: var(--surface); stroke: var(--sel); stroke-width: 1.8; }
#profChart .handle:hover .knob, #tsChart .handle:hover .knob { fill: var(--sel); }
#tsChart .knob.sm { stroke-width: 1.4; }
#iChart { 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; }
.halo { paint-order: stroke; stroke: var(--halo); stroke-width: 3.5px; stroke-linejoin: round; }
.mo-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .mo-row { grid-template-columns: minmax(0, 1fr); } }

/* phones and narrow windows: drawing, verdict, panel, then the rest */
@media (max-width: 1040px) {
  main.mo .work { display: contents; }
  main.mo > * { order: 3; }
  main.mo .stage { order: 0; }
  main.mo .summary { order: 1; min-height: 0; }
  main.mo .panel { order: 2; contain: none; max-height: none; }
}
@media (max-width: 560px) {
  .mech-pick { order: 5; width: 100%; margin-left: 0; flex-wrap: wrap; }
  .mech-pick .mp-name { flex: 1; text-align: right; }
}
/* the verdict stays beside the figures down to phone width */
@media (min-width: 701px) { main.mo .summary { grid-template-columns: auto minmax(0, 1fr); } }
#steps .eq { line-height: 2.4; padding: 2px 0; }
#steps .eq > .katex { white-space: normal; }

/* the panel fades out at an edge it scrolls past (fadePanel in app.js) */
#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); }
/* the density row: a short label, so "Aluminium · 0.1012 lb/in³" fits the select on a phone */
.f.sel:has(> select[data-dens]) { grid-template-columns: 96px minmax(0, 1fr); }

/* dark parts (ball nut, carriage) in dark, picked by hand: --steel-750 mirrors to a bright #969faa slab; a mid steel
   keeps them a solid darker steel without a glowing block */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --mo-dark-part: #565d66; }
}
@media screen {
  :root[data-theme="dark"] { --mo-dark-part: #565d66; }
}
/* 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-3e464f: #a3aab3; --x-4f5862: #929aa3; --x-6e7177: #85827f; --x-7c3aed: #af9af8; --x-a16207: #d8a067;
    --x-be185d: #ee829f; --x-c9d3e6: #363c49; --x-cfd4d9: #3d3b38;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-3e464f: #a3aab3; --x-4f5862: #929aa3; --x-6e7177: #85827f; --x-7c3aed: #af9af8; --x-a16207: #d8a067;
    --x-be185d: #ee829f; --x-c9d3e6: #363c49; --x-cfd4d9: #3d3b38;
  }
}
/* theme-auto:end */
