/* Slider–Crank Dynamics Lab — "LaTeX paper on a dark viewer" theme */
:root {
  --backdrop: #0e0e10;
  --backdrop-2: #17171a;
  --chrome-line: #26262b;
  --chrome-text: #ececec;
  --chrome-muted: #9a9aa2;
  --paper: #ffffff;
  --ink: #141414;
  --ink-2: #474747;
  --ink-3: #8a8a8a;
  --rule: #dcdcdc;
  --red: #a3142a;
  --red-line: #c97a85;
  --red-wash: #fdf6f7;
  --blue: #1f77b4;
  --accent: #4a5df9;
  --accent-2: #3a4ce0;
  --font: "KaTeX_Main", "Latin Modern Roman", "CMU Serif", "Times New Roman", Times, serif;
  --font-math: "KaTeX_Math", "Latin Modern Math", "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --panel-w: 352px;
  --topbar-h: 58px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--backdrop); color: var(--chrome-text);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
kbd, code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .86em; }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 60; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: rgba(14, 14, 16, .9); backdrop-filter: saturate(140%) blur(10px); -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--chrome-line); font-family: var(--font-ui);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: #1d1d22; color: #f2f2f2; border: 1px solid #2c2c33; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-weight: 650; font-size: 15px; letter-spacing: .1px; white-space: nowrap; }
.brand-text small { color: var(--chrome-muted); font-size: 12px; white-space: nowrap; }
.tb-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tb-select { display: flex; align-items: center; gap: 6px; color: var(--chrome-muted); font-size: 13px; }
.tb-select select {
  background: #1b1b20; border: 1px solid #2f2f37; border-radius: 8px; color: var(--chrome-text);
  padding: 6px 28px 6px 10px; font-size: 13px; max-width: 230px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #aaa 50%), linear-gradient(135deg, #aaa 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 7px 14px; font-family: var(--font-ui); font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; line-height: 1.2;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: #34343c; color: var(--chrome-text); }
.btn.ghost:hover { background: #1d1d23; }
.btn.ghost.on { border-color: var(--accent); color: #c7cdff; background: rgba(74, 93, 249, .12); }
.btn.tiny { padding: 3px 10px; font-size: 12px; background: #f1f1f1; color: var(--ink); border-color: #ddd; }
.btn.tiny:hover { background: #e7e7e7; }
.btn:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------ layout */
.layout {
  display: grid; grid-template-columns: var(--panel-w) minmax(0, 1fr); gap: 28px;
  max-width: 1500px; margin: 0 auto; padding: 24px 24px 80px;
}
.pages { display: flex; flex-direction: column; gap: 28px; min-width: 0; }

/* ------------------------------------------------------------ paper */
.panel, .sheet { background: var(--paper); color: var(--ink); }
.sheet {
  position: relative; padding: 44px 56px 56px; max-width: 980px; width: 100%; margin: 0 auto;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .03), 0 18px 40px rgba(0, 0, 0, .5);
}
.sheet h1, .sheet h2 { text-align: center; font-weight: 700; margin: 4px 0 2px; letter-spacing: .1px; }
.sheet h1 { font-size: 1.62rem; }
.sheet h2 { font-size: 1.42rem; }
.sheet h3 { font-size: 1.12rem; margin: 6px 0 10px; }
.center { text-align: center; }
.sheet p { margin: 10px 0; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.sheet .sub { text-align: center; color: var(--ink-2); margin: 2px 0 18px; font-size: .97rem; }
.byline { text-align: center !important; margin: 4px 0 !important; }
.byline.small { font-size: .9rem; color: var(--ink-2); margin-bottom: 22px !important; }
.muted { color: var(--ink-3); }
.small { font-size: .88rem; }
.sheet a { color: var(--red); text-decoration: none; }
.sheet a:hover { text-decoration: underline; }
.page-no { position: absolute; left: 0; right: 0; bottom: 16px; text-align: center; color: var(--ink-3); font-size: .85rem; }
.tag { display: block; width: fit-content; margin: 18px auto 12px; padding: 0 6px; border: 1px solid var(--red-line); color: var(--red); font-size: .95rem; min-height: 1.5em; }
.tag .katex { color: var(--red); }
.sheet .tag:first-child { margin-top: 0; }

.eqbox { border: 1px solid var(--red-line); color: var(--red); padding: 10px 16px; margin: 14px 0; overflow-x: auto; overflow-y: hidden; }
.eqbox .katex { color: var(--red); }
.eqbox.soft { border-style: dashed; }
.eq { margin: 6px 0; text-align: center; }
.eq .katex-display { margin: 4px 0; }
.katex { font-size: 1.06em; }
.eqbox.result { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; padding: 12px 14px; }
.eqbox.result .ri { white-space: nowrap; }
.eqbox.result .ri.warn .katex, .eqbox.result .ri.warn { color: #b35a00; }

.dataline { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--red); padding: 8px 14px; border: 1px solid var(--red-line); }
.dataline .katex { color: var(--red); }
.todo { padding-left: 1.4em; margin: 6px 0; }
.todo li { margin: 3px 0; }
.hint { font-size: .9rem; color: var(--ink-2); text-align: center !important; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--red-line); }
.kpi { padding: 10px 12px 9px; border-right: 1px solid #f0d9dc; border-bottom: 1px solid #f0d9dc; position: relative; min-width: 0; }
.kpi:nth-child(4n) { border-right: none; }
.kpi-sym { color: var(--red); font-size: .95rem; height: 1.6em; }
.kpi-sym .katex { color: var(--red); }
.kpi-val { color: var(--red); font-size: 1.28rem; line-height: 1.25; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi-val .u { font-size: .78rem; color: #b8636f; margin-left: 3px; }
.kpi-lab { font-size: .8rem; color: var(--ink-2); line-height: 1.25; margin-top: 2px; }
.kpi-x { font-size: .74rem; color: var(--ink-3); }
.delta { position: absolute; top: 9px; right: 9px; font-family: var(--font-ui); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 10px; background: #f2f2f2; color: #444; display: none; }
.delta.on { display: block; }
.delta.up { background: #fde8eb; color: #a3142a; }
.delta.down { background: #e6f0fa; color: #1b5f93; }

/* figures */
.fig { position: relative; width: 100%; margin: 6px 0; }
.fig-stack .fig { margin: 0; }
.fig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.caption { font-size: .92rem; color: var(--ink-2); text-align: center !important; margin: 4px 0 16px !important; }
.fig-toolbar { display: flex; justify-content: flex-end; gap: 14px; font-size: .9rem; color: var(--ink-2); margin-top: 12px; }
.fig-toolbar select { border: none; border-bottom: 1px solid #bbb; background: transparent; padding: 2px 4px; color: var(--red); }
.plot { position: relative; touch-action: pan-y; }
.plot canvas { position: absolute; left: 0; top: 0; display: block; }
.plot-over { cursor: crosshair; }
.plot-tip {
  position: absolute; left: 0; top: 0; pointer-events: none; z-index: 5; opacity: 0; transition: opacity .1s;
  background: rgba(255, 255, 255, .97); border: 1px solid #cfcfcf; border-radius: 3px; padding: 5px 8px;
  font-size: 12.5px; line-height: 1.45; color: var(--ink); box-shadow: 0 2px 10px rgba(0, 0, 0, .12); white-space: nowrap;
}
.plot-tip.on { opacity: 1; }
.plot-tip .tt-h { color: var(--red); margin-bottom: 1px; }
.plot-tip .tt-f { color: var(--ink-3); font-size: 11px; }
.plot-tip .sw { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 5px; }
.plot-tip b { font-weight: 400; color: var(--ink); font-variant-numeric: tabular-nums; }
i.mi { font-family: var(--font-math); font-style: italic; }
sub, sup { font-size: .72em; line-height: 0; }

/* mechanism */
.mech-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 2px 0; }
.stroke-name { font-variant: small-caps; letter-spacing: .06em; font-size: 1.08rem; color: var(--red); }
.psi-label { color: var(--ink-2); font-size: .95rem; font-variant-numeric: tabular-nums; }
.mech-wrap { width: 100%; display: flex; justify-content: center; }
.mech-svg { width: 100%; height: auto; max-height: 400px; display: block; }
.mech-svg.vertical { height: 470px; max-height: 470px; width: auto; max-width: 100%; }
.mech-svg text { user-select: none; }
.mech-edge { stroke: #111; stroke-width: 1.5; }
.mech-axis { stroke: #555; stroke-width: .8; stroke-dasharray: 14 4 2 4; }
.mech-support { fill: #fff; stroke: #111; stroke-width: 1.4; }
.mech-disc { fill: #ececec; stroke: #555; stroke-width: 1.2; }
.mech-cw { fill: #c8c8c8; stroke: #555; stroke-width: 1; }
.mech-spoke { stroke: #9a9a9a; stroke-width: 1.6; }
.mech-path { fill: none; stroke: #777; stroke-width: 1; stroke-dasharray: 4 4; }
.mech-gas { stroke: none; transition: fill .08s linear; }
.mech-piston { fill: #d6d6d6; stroke: #111; stroke-width: 1.5; }
.mech-ring { stroke: #333; stroke-width: 1; }
.mech-link-o { stroke: #111; stroke-linecap: round; }
.mech-link-i { stroke: #fff; stroke-linecap: round; }
.mech-pin { fill: #fff; stroke: #111; stroke-width: 1.6; }
.mech-cg { fill: #111; }
.mech-arc { fill: none; stroke: #111; stroke-width: 1; }
.mech-omega { fill: none; stroke: #111; stroke-width: 1.2; }
.mech-dimline { stroke: #111; stroke-width: 1; }
.mech-ext { stroke: #777; stroke-width: .8; }
.mech-label, .mech-flabel, .mech-small { paint-order: stroke; stroke: #fff; stroke-width: 3.5px; stroke-linejoin: round; }
.mech-label { font-family: var(--font-math); font-style: italic; font-size: 17px; fill: #111; }
.mech-label.small { font-size: 14px; }
.mech-small { font-family: var(--font); font-size: 11.5px; fill: #555; letter-spacing: .04em; }
.mech-sub { font-size: 11px; }
.mech-farrow { stroke: var(--red); stroke-width: 2.2; }
.mech-flabel { font-family: var(--font-math); font-style: italic; font-size: 15px; fill: var(--red); }
.transport { display: flex; align-items: center; gap: 12px; margin: 10px 0 2px; }
.transport input[type=range] { flex: 1; }
.scrub-val { min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.transport2 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; font-size: .9rem; color: var(--ink-2); }
.transport2 label { display: flex; align-items: center; gap: 8px; }
.transport2 input[type=range] { width: 130px; }
.btn.round { width: 38px; height: 38px; padding: 0; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; flex: none; }
.btn.round.small { width: 28px; height: 28px; }
.btn.round:hover { background: var(--red); }
.ic-pause, .ic-play { display: block; }
.ic-pause { width: 10px; height: 12px; border-left: 3.5px solid #fff; border-right: 3.5px solid #fff; }
.ic-play { width: 0; height: 0; border-left: 11px solid #fff; border-top: 7px solid transparent; border-bottom: 7px solid transparent; margin-left: 3px; }
.small .ic-pause { width: 8px; height: 10px; border-width: 0 3px; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.chk input { accent-color: var(--red); }
.inst { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px 18px; font-size: .97rem; }
.inst .it { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; border-bottom: 1px dotted #efd2d6; padding: 2px 0; }
.inst .it .v { font-variant-numeric: tabular-nums; color: var(--red); }
.inst .it .v small { color: #b8636f; font-size: .8em; margin-left: 2px; }

/* verification tables */
.table-wrap { overflow-x: auto; }
.vt { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.vt th, .vt td { padding: 5px 8px; text-align: right; border-bottom: 1px solid #ececec; white-space: nowrap; }
.vt th:first-child, .vt td:first-child { text-align: left; white-space: normal; }
.vt thead th { border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--ink); font-weight: 700; }
.vt tbody tr:last-child td { border-bottom: 1.5px solid var(--ink); }
.ok { color: #1a7f37; font-weight: 700; }
.bad { color: #c01a1a; font-weight: 700; }

/* notes */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 32px; }
.nom { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; font-size: .93rem; }
.nom dt { color: var(--red); white-space: nowrap; }
.nom dt .katex { color: var(--red); }
.nom dd { margin: 0; color: var(--ink-2); }
.tight { padding-left: 1.2em; margin: 4px 0; font-size: .93rem; }
.tight li { margin: 3px 0; }
.refs { font-size: .9rem; padding-left: 1.4em; }

/* ------------------------------------------------------------ data panel */
.panel {
  position: sticky; top: calc(var(--topbar-h) + 24px); align-self: start;
  max-height: calc(100vh - var(--topbar-h) - 48px); overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 20px 18px; box-shadow: 0 18px 40px rgba(0, 0, 0, .5); scrollbar-width: thin;
}
.panel-head { display: flex; align-items: center; gap: 10px; }
.panel-head h2 { margin: 0; font-size: 1.35rem; font-weight: 700; flex: 1; }
.panel-close { display: none; border: none; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--ink-2); padding: 0 4px; }
.panel-note { font-size: .82rem; color: var(--ink-2); margin: 6px 0 4px; line-height: 1.4; }
.panel-foot { font-size: .78rem; color: var(--ink-3); margin: 12px 0 0; text-align: center; }
.grp { margin: 10px 0 0; }
.grp > summary {
  list-style: none; cursor: pointer; font-variant: small-caps; letter-spacing: .05em; font-size: 1.04rem; font-weight: 700;
  border-bottom: 1px solid var(--ink); padding: 2px 0 2px; display: flex; justify-content: space-between; align-items: center;
}
.grp > summary::-webkit-details-marker { display: none; }
.grp > summary::after { content: "−"; font-variant: normal; color: var(--ink-3); font-weight: 400; }
.grp:not([open]) > summary::after { content: "+"; }
.ctl { padding: 7px 0 5px; border-bottom: 1px dotted #e3e3e3; transition: opacity .2s; }
.ctl.off { opacity: .38; }
.ctl-head { display: flex; align-items: baseline; gap: 6px; }
.ctl-sym { color: var(--red); min-width: 34px; font-size: .95rem; }
.ctl-sym .katex { color: var(--red); }
.ctl-name { flex: 1; font-size: .84rem; color: var(--ink-2); line-height: 1.25; min-width: 0; }
.ctl input[type=number] {
  width: 74px; text-align: right; border: none; border-bottom: 1px solid #c5c5c5; background: transparent;
  color: var(--red); padding: 0 2px; font-size: .95rem; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.ctl input[type=number]::-webkit-inner-spin-button, .ctl input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ctl input[type=number]:focus { outline: none; border-bottom-color: var(--red); }
.ctl-unit { min-width: 30px; font-size: .78rem; color: var(--ink-3); }
.ctl select {
  width: 100%; margin-top: 4px; border: none; border-bottom: 1px solid #c5c5c5; background: transparent; padding: 3px 0;
  color: var(--red); font-size: .92rem; cursor: pointer;
}
.ctl select:focus { outline: none; border-bottom-color: var(--red); }

/* range inputs: hairline track, small round thumb */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; margin: 2px 0 0; }
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(to right, var(--red) 0 var(--fill, 0%), #cfcfcf var(--fill, 0%) 100%); border-radius: 1px; }
input[type=range]::-moz-range-track { height: 2px; background: #cfcfcf; border-radius: 1px; }
input[type=range]::-moz-range-progress { height: 2px; background: var(--red); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: #fff; border: 1.6px solid var(--ink); transition: transform .1s, border-color .1s; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 1.6px solid var(--ink); }
input[type=range]:hover::-webkit-slider-thumb, input[type=range]:focus-visible::-webkit-slider-thumb { border-color: var(--red); transform: scale(1.15); }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(163, 20, 42, .2); }

/* ------------------------------------------------------------ picture-in-picture mechanism */
.pip {
  position: fixed; right: 44px; bottom: 22px; width: 300px; background: var(--paper); color: var(--ink); z-index: 45;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .55); padding: 6px 8px 8px; transform: translateY(14px); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.pip.show { opacity: 1; transform: none; pointer-events: auto; }
.pip-host .mech-svg { max-height: 150px; }
.pip-host .mech-svg.vertical { height: 190px; max-height: 190px; }
.pip-bar { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pip-bar span { flex: 1; }
.pip-link { color: var(--red); text-decoration: none; font-size: .82rem; }
.pip-close { border: none; background: none; color: var(--ink-3); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.pip-close:hover { color: var(--ink); }

.fab { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #f4f4f4; color: #111; font-family: var(--font-ui);
  font-size: 14px; padding: 9px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.noscript { color: #fff; text-align: center; padding: 40px; }

/* ------------------------------------------------------------ hero (mechanism first) */
.hero h1 { font-size: 1.5rem; }
.hero .sub { max-width: 760px; margin-left: auto; margin-right: auto; }
.mini-h { font-size: .98rem !important; font-variant: small-caps; letter-spacing: .05em; margin: 18px 0 6px !important; color: var(--ink-2); }
.preset-row { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; font-size: .86rem; color: var(--ink-2); }
.preset-row select {
  flex: 1; min-width: 0; border: 1px solid #d6d6d6; border-radius: 6px; background: #fafafa; padding: 5px 8px; color: var(--red); font-size: .9rem; cursor: pointer;
}
.preset-row select:focus { outline: none; border-color: var(--red); }

/* ------------------------------------------------------------ section tabs (carousel-like) */
.tabs {
  position: sticky; top: var(--topbar-h); z-index: 30; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 2px; margin: 0 auto -14px; max-width: 980px; width: 100%; background: var(--backdrop);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 1px solid #34343c; background: #18181c; color: #cfcfd4; border-radius: 18px; padding: 6px 14px;
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.tab:hover { background: #222228; color: #fff; }
.tab[aria-selected="true"] { background: #fff; color: var(--ink); border-color: #fff; }
.tab-page[hidden] { display: none; }

/* ------------------------------------------------------------ observations: what the results say */
.obs { border-left: 3px solid var(--red); background: var(--red-wash); padding: 8px 14px 8px 12px; margin: 12px 0 18px; }
.obs-h { font-variant: small-caps; letter-spacing: .05em; color: var(--red); font-size: .95rem; margin-bottom: 2px; }
.obs ul { margin: 0; padding-left: 1.1em; }
.obs li { margin: 3px 0; font-size: .95rem; line-height: 1.45; }
.obs b { font-weight: 700; color: var(--ink); }

/* ------------------------------------------------------------ step-by-step solution */
.ws-controls { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 16px; margin: 4px 0 10px; font-size: .95rem; }
.ws-controls input[type=number] {
  width: 70px; text-align: right; border: none; border-bottom: 1px solid #c5c5c5; color: var(--red); font-size: 1rem; background: transparent;
  -moz-appearance: textfield; appearance: textfield;
}
.ws-controls input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
.ws-quick { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border: 1px solid #d0d0d0; background: #fafafa; border-radius: 14px; padding: 2px 10px; font: inherit; font-size: .85rem; cursor: pointer; color: var(--ink); }
.chip:hover, .chip.on { border-color: var(--red); color: var(--red); }
.steps { counter-reset: st; list-style: none; padding: 0; margin: 8px 0; }
.steps > li { counter-increment: st; position: relative; padding: 8px 0 8px 40px; border-bottom: 1px dotted #e3e3e3; }
.steps > li::before {
  content: counter(st); position: absolute; left: 0; top: 9px; width: 26px; height: 26px; border: 1px solid var(--red-line); color: var(--red);
  display: grid; place-items: center; font-size: .9rem;
}
.steps > li.cont { counter-increment: none; padding-top: 0; margin-top: -6px; }
.steps > li.cont::before { display: none; }
.step-t { font-weight: 700; font-size: .97rem; }
.step-t span { font-weight: 400; color: var(--ink-2); }
.step-eq { color: var(--red); overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.step-eq .katex { color: var(--red); }
.step-eq .katex-display { margin: 4px 0; text-align: left; }
.step-eq .katex-display > .katex { text-align: left; }

/* ------------------------------------------------------------ velocity / acceleration polygons */
.poly-wrap { width: 100%; max-width: 720px; margin: 6px auto 4px; }
.poly-svg { width: 100%; height: auto; display: block; }
.poly-frame { fill: #fff; stroke: #e2e2e2; }
.poly-title { font-family: var(--font); font-variant: small-caps; letter-spacing: .05em; font-size: 14px; fill: #555; }
.poly-vec { stroke-width: 2; }
.poly-vec.k { stroke: #111; }
.poly-vec.r { stroke: var(--red); }
.poly-vec.b { stroke: #1f77b4; }
.poly-vec.g { stroke: #2ca02c; stroke-dasharray: 5 3; }
.poly-lab { font-family: var(--font-math); font-style: italic; font-size: 16px; fill: #111; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.vt.compact th, .vt.compact td { padding: 3px 8px; font-size: .9rem; }
.vt .hl td { background: #fdf0f2; }
.vt td .sw { display: inline-block; width: 14px; height: 2.5px; vertical-align: middle; margin-right: 6px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1280px) {
  :root { --panel-w: 330px; }
  .layout { gap: 22px; padding-right: 24px; }
  .sheet { padding: 38px 40px 48px; }
}
@media (max-width: 1060px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 80px; }
  /* parameters sit right under the animation, never hidden */
  #panelSlot .panel { position: static; max-height: none; overflow: visible; box-shadow: none; padding: 6px 0 0; margin: 16px 0 6px; border-top: 1px solid var(--ink); }
  #panelSlot .panel-head h2 { font-size: 1.15rem; }
  .fab {
    display: block; position: fixed; left: 50%; transform: translate(-50%, 90px); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 65;
    background: var(--accent); color: #fff; border: none; border-radius: 22px; padding: 10px 20px; font-family: var(--font-ui); font-weight: 650;
    font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); cursor: pointer; transition: transform .2s; pointer-events: none;
  }
  .fab.show { transform: translate(-50%, 0); pointer-events: auto; }
  .pip { right: 12px; bottom: 72px; width: 230px; }
  .tabs { margin-bottom: -10px; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .brand-text small { display: none; }
  .brand-text b { font-size: 14px; }
  .hide-sm { display: none; }
  .btn { padding: 7px 10px; }
  .sheet { padding: 24px 14px 30px; }
  .sheet h1, .hero h1 { font-size: 1.28rem; }
  .sheet h2 { font-size: 1.16rem; }
  .sheet p { text-align: left; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(4n) { border-right: 1px solid #f0d9dc; }
  .kpi:nth-child(2n) { border-right: none; }
  .fig-grid, .cols { grid-template-columns: minmax(0, 1fr); }
  .inst { grid-template-columns: repeat(2, minmax(0, 1fr)); font-size: .9rem; }
  .eqbox { padding: 8px 10px; }
  .katex { font-size: 1em; }
  .mech-svg { max-height: 300px; }
  .mech-svg.vertical { height: 340px; }
  .pip { width: 168px; right: 10px; padding: 4px 6px 6px; }
  .pip-host .mech-svg { max-height: 96px; }
  .pip-host .mech-svg.vertical { height: 130px; max-height: 130px; }
  .pip-link { display: none; }
  .pip-bar { font-size: .74rem; gap: 5px; }
  .mech-head { flex-direction: column; gap: 0; }
  .brand-mark { width: 32px; height: 32px; }
  .steps > li { padding-left: 34px; }
  .ws-controls { grid-template-columns: 1fr; }
  .tab { font-size: 13px; padding: 6px 12px; }
}
@media (max-width: 420px) {
  .brand-text { display: none; }
  .inst { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------ print: every section, no chrome */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .topbar, .panel, .tabs, .pip, .fab, .toast, .transport, .transport2, .fig-toolbar, .ws-controls, .hint { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .tab-page[hidden] { display: block !important; }
  .sheet { box-shadow: none; padding: 0 0 24px; max-width: none; break-after: page; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
