/* hydraulic cylinder — on top of calc.css */
#view { display: block; width: 100%; height: auto; flex: 1; min-height: 0; user-select: none; touch-action: none; }
#view .rod, #view .rodend { cursor: ew-resize; }
#view.dragging, #view.dragging * { cursor: grabbing !important; }
#view .handle { cursor: grab; }
#view .handle .knob { fill: var(--surface); stroke: var(--sel); stroke-width: 1.8; }
#view .handle:hover .knob { fill: var(--sel); }
.cy-dim { font-size: 11.5px; fill: var(--text-2); }
.cy-load { font-size: 12px; font-weight: 600; fill: var(--load); }
#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.p rect { fill: color-mix(in srgb, var(--surface) 92%, transparent); stroke: color-mix(in srgb, var(--sel) 35%, transparent); }
#view .pill.p text { fill: var(--x-1e4fbf, #1e4fbf); font-weight: 600; }
#view .pill.hot rect, #view .pill.bad rect { stroke: var(--bad); } #view .pill.hot text, #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 .flow { stroke: var(--sel); stroke-width: 1.8; stroke-dasharray: 5 4; fill: none; animation: cyflow 1.6s linear infinite; }
#view .flow.hot { stroke: var(--bad); }
#view .flow.regen { stroke-width: 1.5; }
body.running #view .flow { animation-duration: .6s; }
@keyframes cyflow { to { stroke-dashoffset: -18; } }

.cy-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; }
.cy-live b { font-weight: 500; color: var(--text-3); margin-right: 4px; }
.cy-live i { font-style: normal; color: var(--text-3); }
.cy-live .clock { margin-left: auto; color: var(--sel); font-weight: 600; }

.stage-bar .btn.small { padding: 4px 10px; font-size: 12.5px; }
#play { min-width: 104px; }
body.running #play { border-color: var(--sel); color: var(--sel); }

/* mounting picker: a quiet list, selected row like the rest of the site */
.mounts { display: grid; gap: 4px; }
.mount { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 5px 10px 5px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font: inherit; font-size: 12.5px; color: var(--text); text-align: left; }
.mount:hover { border-color: var(--line-2); }
.mount.on { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.mount span small { color: var(--text-3); font-size: 11.5px; }
.mount b { font-weight: 500; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mount.on b { color: var(--text-2); }

/* extend / retract / regenerative compared */
.cy-sum { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
.cy-motion { padding: 8px 20px 12px; min-width: 0; overflow-x: auto; }
.cy-mini { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); border-left: 1px solid var(--line); }
.cy-mini .stat { border-left: 0; border-top: 1px solid var(--line); }
.cy-mini .stat:nth-child(-n+2) { border-top: 0; }
.cy-mini .stat:nth-child(even) { border-left: 1px solid var(--line); }
.cy-motion table { border-collapse: collapse; }
.cy-motion thead th { padding: 6px 28px 8px 0; text-align: left; }
.cy-motion thead th:first-child { width: 110px; }
.cy-motion thead span { display: inline-block; border: 0; background: none; padding: 4px 0; font: inherit; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; }
.cy-motion thead span.on { color: var(--text); border-bottom-color: var(--text); }
.cy-motion tbody th { text-align: left; font-weight: 400; font-size: 12.5px; color: var(--text-3); padding: 6px 0; border-top: 1px solid var(--fill-1); }
.cy-motion td { padding: 6px 28px 6px 0; border-top: 1px solid var(--fill-1); white-space: nowrap; }
.cy-motion .mv-v { display: inline-block; min-width: 96px; font-size: 13.5px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.cy-motion td.on .mv-v { color: var(--text); font-weight: 500; }
.cy-motion .mv-bar { display: inline-block; vertical-align: middle; width: 72px; height: 4px; background: var(--fill-1); border-radius: 2px; overflow: hidden; }
.cy-motion .mv-bar i { display: block; height: 100%; background: var(--steel-350); border-radius: 2px; }
.cy-motion td.on .mv-bar i { background: var(--steel-700); }
.mv-note { margin: 8px 0 0; font-size: 12px; color: var(--text-3); }
#view .pill.dimv rect { fill: var(--surface); stroke: var(--steel-200); }
#view .pill.dimv text { fill: var(--text-2); font-weight: 500; }
.cy-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cy-charts svg { display: block; width: 100%; height: auto; }
.ch-t { font-size: 10.5px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.ch-a { font-size: 11px; fill: var(--text-2); }
.cy-empty { font-size: 12px; color: var(--text-2); text-align: center; line-height: 1.4; }
#checks tr[data-check] { cursor: pointer; }
#checks tr.sel td { background: var(--sel-bg); }

@media (max-width: 1100px) { .cy-sum { grid-template-columns: minmax(0, 1fr); } .cy-mini { border-left: 0; border-top: 1px solid var(--line); } .cy-mini .stat:nth-child(-n+2) { border-top: 0; } }
@media (max-width: 900px) {
  .cy-charts { grid-template-columns: minmax(0, 1fr); }
  .cy-motion thead th:first-child { width: 84px; }
}
.cy-motion tbody th { white-space: nowrap; padding-right: 22px; }

/* values in the drawing are editable */
#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; }
.cy-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); }
.cy-edit input { width: 82px; border: 0; outline: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; padding: 3px 2px; }
.cy-edit span { font-size: 11.5px; color: var(--text-3); }
main.cyl .stage-bar { justify-content: flex-start; gap: 8px; }
main.cyl .stage-bar .hist { margin-left: auto; }

/* motion table fits its card: no scrolling, bars shrink first */
.cy-motion { overflow: visible; }
.cy-motion table { width: 100%; table-layout: fixed; }
.cy-motion thead th:first-child, .cy-motion tbody th { width: 92px; }
.cy-motion td { padding-right: 18px; }
.cy-motion td > .mv-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cy-motion .mv-v { min-width: 0; flex: none; }
.cy-motion .mv-bar { flex: 1 1 auto; width: auto; max-width: 72px; min-width: 16px; }
@media (max-width: 1320px) {
  .cy-sum { grid-template-columns: minmax(0, 1fr); }
  .cy-mini { grid-template-columns: repeat(4, minmax(0, 1fr)); border-left: 0; border-top: 1px solid var(--line); }
  .cy-mini .stat { border-top: 0; border-left: 1px solid var(--line); }
  .cy-mini .stat:first-child { border-left: 0; }
}
@media (max-width: 700px) {
  .cy-mini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cy-motion .mv-bar { display: none; }
}

/* cutaway parts: one quiet palette */
#view .part { fill: var(--steel-200); stroke: var(--steel-600); stroke-width: 1; }
#view .hole { fill: var(--surface); stroke: var(--steel-700); stroke-width: 1.2; }
#view .barrel { fill: var(--steel-100); stroke: var(--steel-600); stroke-width: 1; }
#view .bore { fill: var(--surface-2); stroke: var(--steel-400); stroke-width: .8; }
#view .piston { fill: var(--x-4f5862, #4f5862); }
#view .seal { fill: var(--steel-550); }
#view .rod { stroke: var(--steel-600); stroke-width: 1; }
#view .tie { stroke: var(--steel-500); stroke-width: 2; }
#view .nut { fill: var(--x-cfd4d9, #cfd4d9); stroke: var(--steel-600); stroke-width: .8; }
#view .brk { fill: none; stroke: var(--steel-700); stroke-width: 1.1; }

/* a size that cannot be built yet (rod ≥ bore, tube inside the bore) is held back while typing */
#panel input.bad { color: var(--bad); }
#panel .num:has(input.bad) { border-color: var(--bad); }


/* reserve the space the script fills, so nothing jumps on load */
main.cyl .summary { min-height: 236px; }
main.cyl .table-wrap { min-height: 330px; }
/* phones and narrow tablets: the verdict right after the drawing, the inputs after it */
@media (max-width: 1040px) {
  main.cyl .work { display: contents; }
  main.cyl > * { order: 3; }
  main.cyl .stage { order: 0; }
  main.cyl .summary { order: 1; min-height: 0; }
  main.cyl .panel { order: 2; }
}
/* the extend / retract / regenerative table on a phone: three value columns that fit without touching */
@media (max-width: 560px) {
  .cy-motion { padding: 6px 14px 12px; }
  .cy-motion thead th:first-child, .cy-motion tbody th { width: 78px; padding-right: 6px; }
  .cy-motion td { padding-right: 8px; }
  .cy-motion thead th { padding-right: 8px; }
  .cy-motion thead span { font-size: 10.5px; letter-spacing: .03em; }
  .cy-motion .mv-v { font-size: 12.5px; }
  .cy-motion tbody th { font-size: 12px; }
  .cy-motion thead .mv-long { display: none; }
}
/* panel labels wrap to a second line instead of ending in an ellipsis (T029 QA) */
.f > label span { overflow: visible; text-overflow: clip; white-space: normal; line-height: 1.3; }

/* 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); }

/* 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-4f5862: #929aa3; --x-6e7177: #85827f; --x-7b848c: #6e767c; --x-9a6a12: #d0a66a;
    --x-cdd2d7: #3e3c39; --x-cfd4d9: #3d3b38; --x-cfd5db: #373b3f; --x-f3d9cf: #403029;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-1e4fbf: #749ff5; --x-4f5862: #929aa3; --x-6e7177: #85827f; --x-7b848c: #6e767c; --x-9a6a12: #d0a66a;
    --x-cdd2d7: #3e3c39; --x-cfd4d9: #3d3b38; --x-cfd5db: #373b3f; --x-f3d9cf: #403029;
  }
}
/* theme-auto:end */
/* dark, picked by hand: the piston a dark steel one step above the tube, not the mirrored ramp's pale block */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #view .piston { fill: #4f555e; }
}
@media screen {
  :root[data-theme="dark"] #view .piston { fill: #4f555e; }
}
