.flex-guide .flex-layouts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-block: 1.5rem;
}

.flex-guide .flex-layout {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--line, #ddd);
  border-radius: 8px;
  background: var(--surface, #f5f5f5);
}

.flex-guide .flex-layout h3 { margin: 0 0 .5rem; }
.flex-guide .flex-layout figcaption { flex: 1; }
.flex-guide .flex-layout figcaption p { margin: 0 0 1rem; }

.flex-shaft {
  position: relative;
  height: 196px;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid var(--line, #ddd);
  border-radius: 5px;
  background: var(--paper, #fff);
  color: var(--ink, #353535);
  --flex-cable: #a34b07;
  --flex-fixed: #646464;
}

html[data-theme="dark"] .flex-shaft {
  --flex-cable: var(--theme-accent);
  --flex-fixed: var(--theme-muted);
}

.flex-panel, .flex-car, .flex-junction {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 4px;
  border: 1px solid var(--line, #c8c8c8);
  border-radius: 4px;
  background: var(--surface, #f5f5f5);
  color: inherit;
  font-size: .8125rem;
  line-height: 1.1;
  text-align: center;
}

.flex-panel { inset: 12px auto auto 8%; width: 32%; min-height: 36px; }
.flex-car { inset: 62px auto auto 57%; width: 37%; height: 50px; }
.flex-junction { inset: 86px auto auto 8%; width: 32%; min-height: 31px; }

.flex-fixed {
  position: absolute;
  top: 47px;
  left: 24%;
  height: 65px;
  border-inline-start: 2px dashed var(--flex-fixed);
}

.flex-fixed-continuous { border-inline-start: 3px solid var(--flex-cable); }
.flex-support {
  position: absolute;
  z-index: 1;
  top: 107px;
  left: calc(24% - 3px);
  width: 9px;
  height: 9px;
  background: currentColor;
  border-radius: 50%;
}

.flex-loop {
  position: absolute;
  top: 111px;
  left: 24%;
  width: 44%;
  height: 61px;
  border: 3px solid var(--flex-cable);
  border-top: 0;
  border-radius: 0 0 37% 37%;
}

.flex-guide .flex-caption, .flex-guide .flex-figure-note {
  color: var(--muted, #575757);
  font-size: .875rem;
}
.flex-guide .flex-caption { margin: .75rem 0 0; }
.flex-references { margin-block-start: 2rem; }
.flex-references summary { cursor: pointer; font-weight: 700; }

@media (max-width: 660px) {
  .flex-guide .flex-layouts { grid-template-columns: 1fr; }
}

.flex-guide .flex-motion {
  margin: 1.5rem 0;
  padding: clamp(.75rem, 3vw, 1.5rem);
  border: 1px solid var(--line, #ddd);
  border-radius: 8px;
  background: var(--surface, #f5f5f5);
}

.flex-motion figcaption strong {
  font-size: 1.125rem;
}

.flex-guide .flex-motion figcaption p { margin: .4rem 0 1rem; }

.flex-motion-shaft {
  --car-travel: 0;
  --car-top: calc(169px - 126px * var(--car-travel));
  --car-height: 58px;
  --shaft-anchor: 126px;
  --bend-bottom: calc(261px - 63px * var(--car-travel));
  --bend-radius: 26px;
  --tangent: calc(var(--bend-bottom) - var(--bend-radius));
  --shaft-end: 24%;
  --car-end: 74%;
  --cable-colour: #a34b07;
  position: relative;
  height: 288px;
  border: 1px solid var(--line, #ddd);
  border-radius: 5px;
  background: var(--paper, #fff);
  color: var(--ink, #353535);
}

html[data-theme="dark"] .flex-motion-shaft { --cable-colour: var(--theme-accent); }

.flex-motion-box {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(42%, 8.5rem);
  padding: .25rem;
  translate: -50% 0;
  border: 1px solid var(--line, #c8c8c8);
  border-radius: 4px;
  background: var(--surface, #f5f5f5);
  line-height: 1.2;
  text-align: center;
  font-size: .875rem;
}

.flex-motion-panel, .flex-motion-junction { left: var(--shaft-end); }
.flex-motion-panel { top: 13px; height: 36px; }
.flex-motion-junction { top: 94px; height: 32px; }
.flex-motion-car { top: var(--car-top); left: var(--car-end); height: var(--car-height); }

.flex-motion-fixed, .flex-motion-leg, .flex-motion-bend { position: absolute; }
.flex-motion-fixed {
  inset: 48px auto auto var(--shaft-end);
  height: 47px;
  border-left: 2px dashed var(--muted, #646464);
}
.flex-motion-leg {
  bottom: calc(100% - var(--tangent) - 1px);
  border-left: 3px solid var(--cable-colour);
}
.flex-motion-leg-fixed { top: calc(var(--shaft-anchor) - 1px); left: var(--shaft-end); }
.flex-motion-leg-car { top: calc(var(--car-top) + var(--car-height) - 1px); left: var(--car-end); }
.flex-motion-bend {
  top: var(--tangent);
  left: var(--shaft-end);
  width: calc(var(--car-end) - var(--shaft-end) + 3px);
  height: var(--bend-radius);
  border: 3px solid var(--cable-colour);
  border-top: 0;
  border-radius: 0 0 var(--bend-radius) var(--bend-radius);
}

.flex-motion-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}
.flex-motion-controls[hidden], .flex-motion-controls button[hidden] { display: none; }
.flex-motion-controls .button { cursor: pointer; min-width: 11rem; justify-content: center; }
.flex-motion-position {
  flex: 1 1 12rem;
  min-width: 0;
  display: grid;
  gap: .25rem;
}
.flex-motion-position label { font-weight: 700; }
.flex-motion-position input {
  width: 100%;
  min-height: 28px;
  margin: 0;
  accent-color: #555;
}
.flex-motion-floors {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  font-size: .8125rem;
  color: var(--muted, #575757);
}


html[data-theme="dark"] .flex-motion-position input { accent-color: #b9bdbd; }

.flex-motion-view { position: relative; }

.flex-model {
  position: relative;
  height: clamp(360px, 57vw, 510px);
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line, #ddd);
  border-radius: 5px;
  background: radial-gradient(ellipse at 50% 40%, #fff, #e6e6e6);
}

html[data-theme="dark"] .flex-model {
  background: radial-gradient(ellipse at 50% 40%, #343434, #1c1c1c);
}

.flex-model[hidden], .flex-motion-shaft[hidden] { display: none; }
.flex-model canvas { display: block; width: 100%; height: 100%; }
.flex-model .model-labels { display: none; }

.flex-guide .flex-motion-key {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .65rem 0 0;
  font-size: .875rem;
}
.flex-motion-key span {
  display: inline-block;
  width: 1.35rem;
  border-top: 4px solid #f68125;
}
